我正在尝试运行一个dockerfile,该文件应服务于jsreport 2.2.0生成的chrome-pdf。这是dockerfile:
FROM node:carbon
ADD . /usr/src/js-report-home
WORKDIR /usr/src/js-report-home
RUN apt-get update && apt-get install -yq libgconf-2-4
RUN apt-get update && apt-get install -y wget --no-install-recommends \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /src/*.deb
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
RUN npm i puppeteer
EXPOSE 5488
RUN npm install
CMD [ "npm", "start" ]
现在运行jsreport时出现以下错误:
Error: Chromium revision is not downloaded. Run "npm install" or "yarn install"
at Launcher.launch (/usr/src/js-report-home/node_modules/puppeteer/lib/Launcher.js:115:15)
at <anonymous>
该错误告诉我要运行npm install,该操作在dockerfile的倒数第二行执行。我还检查了铬,它实际上安装在以下位置:puppeteer> .local-chromium> win64-579032> chrome-win32
有帮助吗?
编辑:我还向jsreport config.json添加了一个扩展名,因此它可以在没有沙箱的情况下启动Chrome。
{
"shortid": "BkvRaEZLQ",
"name": "1_Factsheet Light",
"recipe": "chrome-pdf",
"engine": "handlebars",
"chrome": {
"printBackground": true
},
"modificationDate": {
"$$date": 1542121945921
},
"_id": "eSKSxylsIUdoPT6Z",
"$entitySet": "templates",
"htmlToXlsx": {
"htmlEngine": "chrome"
},
"phantom": {
"waitForJS": true,
"fitToPage": false
},
"data": {
"shortid": "rkuN61P67"
},
"extensions": {
"chrome-pdf": {
"launchOptions": {
"args": ["--no-sandbox"]
}
}
}
}
答案 0 :(得分:0)
您需要配置jsreport / puppeteer以使用通过apt-get install -y google-chrome-unstable
明确下载的二进制文件。这是通过
ENV chrome:launchOptions:executablePath google-chrome-unstable
我建议您看一下官方的jsreport图片。您会在那找到它。 https://hub.docker.com/r/jsreport/jsreport/
中找到dockerfiles