AWS - Running Puppeteer on AWS EC2

Launch browser with...

this.browser = await puppeteer.launch({
    executablePath: process.env.CHROMIUM_PATH,
    args: ['--no-sandbox', '--disable-setuid-sandbox'],
});

Add to Dockerfile

FROM node:12-alpine

// ----------------------------------------
RUN apk add --no-cache chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV CHROMIUM_PATH /usr/bin/chromium-browser
// ----------------------------------------

WORKDIR /usr/src/app

COPY package.json .
COPY yarn.lock .
RUN yarn

COPY . .

EXPOSE 3200

CMD ["yarn", "start:dev"]

Last updated

Was this helpful?