July 30, 2026

Deploying Puppeteer with Docker

A guide to deploying Puppeteer with Docker

FROM node:18-slim
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
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 google-chrome-stable -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
COPY . .
RUN npm install
RUN npm run build
EXPOSE 8000
CMD ["node", "server.js"]
const browser: Browser = await puppeteer.launch({
headless: 'new',
...(process.env['NODE_ENV'] !== 'local' && {
executablePath: '/usr/bin/google-chrome',
args: [
'--ignore-certificate-errors',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-accelerated-2d-canvas',
'--disable-gpu',
],
}),
})