node.js + puppeteer 生成截图功能的 docker 镜像脚本

文件名称:Dockerfile

执行命令:docker build -t <你的镜像名称> .

eg:docker build -t node-puppeteer .

注意:尽量走代理 因为有些镜像源无法下载  

参考文档:

https://github.com/puppeteer/puppeteer/blob/main/.ci/node12/Dockerfile.linux;

https://github.com/puppeteer/puppeteer

https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

https://eggjs.org/zh-cn/core/deployment.html

https://medium.com/@christopher.talke/using-node-puppeteer-with-docker-without-wanting-to-smash-your-keyboard-ed78e9529a8b


## dome
## node.js + puppeteer 生成截图的 docker打包镜像脚本 
# FROM node:12
# ENV NODE_ENV=production
# WORKDIR /app
# COPY [".npmrc", "package.json", "package-lock.json", "./"]
# 安装一些puppeteer基础依赖 ps:尽量采用外网访问走代理
# RUN apt-get update && \
#     apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
#       libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
#       libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \
#       libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
#       libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget && \
#     rm -rf /var/lib/apt/lists/*
# RUN  mkdir -p /home/pptruser/Downloads
# 通过npm去安装依赖包 ps:之所以要在这里处理因为遇到了镜像缓慢问题  
# RUN npm config set sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
# RUN npm config set sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"
# RUN npm install sharp
# RUN npm install --production --loglevel verbose

# COPY ["config", "./config/"]
# COPY ["app", "./app/"]

# EXPOSE 7001
# ENTRYPOINT ["npm","run","start"]

菜鸟的学习之路,如有不对欢迎指正

上一篇:Puppeteer--爬坑记录


下一篇:安装puppeteer