share the dockerfile I'm using
shuiRong opened this issue · 0 comments
shuiRong commented
Convenient for those who are not familiar with Docker
Dockerfile:
# 官方文档 https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
# 从puppeteer 官方镜像
FROM alpine:edge
# 应用程序工作目录
WORKDIR /home/docker/site_fetcher
# 安装最新版 Chromium (89) 包.
RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs \
yarn
# 跳过自动安装chrome包. 使用上面已经安装的chrome.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
# 绑定应用程序
COPY . /home/docker/site_fetcher
RUN yarn install
# yarn install && \
# yarn cache clean
VOLUME ["/logs"]
# 端口对应
EXPOSE 3000
# 启动服务命令
CMD [ "node", "index.js" ]
and add no-sandbox
to the launcher config.
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: 10,
monitor: true,
puppeteerOptions: {
args: [
'--no-sandbox',
'--disable-setuid-sandbox', // uid沙盒
// '--disable-web-security',
// '--ignore-certificate-errors',
// '--ignore-autoplay-restrictions',
// '--disable-background-timer-throttling',
// '--lang=en',
// '--incognito',
// '–no-first-run', // 没有设置首页。在启动的时候,就会打开一个空白页面。
],
headless: true,
},
});