Skip to content

Instantly share code, notes, and snippets.

@huantt
Last active May 7, 2022 09:18
Show Gist options
  • Select an option

  • Save huantt/a3ba2190bc4e96c4cdfb51a24e2507c8 to your computer and use it in GitHub Desktop.

Select an option

Save huantt/a3ba2190bc4e96c4cdfb51a24e2507c8 to your computer and use it in GitHub Desktop.
puppeteer dockerfile - capture html to image
FROM node:14-slim
WORKDIR /usr/src/app
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& 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-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
ARG PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
COPY package*.json ./
RUN npm install
COPY . .
RUN npm init -y && \
npm i puppeteer \
&& groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser node_modules \
&& chown -R pptruser:pptruser package.json \
&& chown -R pptruser:pptruser package-lock.json
ENV PORT=3000
USER pptruser
CMD ["npm","start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment