Created
July 27, 2022 06:52
-
-
Save marten-cz/b67f7816546e7cb14d6ee6dcfc7cd473 to your computer and use it in GitHub Desktop.
Docker with puppeteer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:16.15.1-alpine3.16 | |
# Create app directory | |
WORKDIR /usr/src/app | |
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true | |
ENV NODE_ENV production | |
ENV PORT 5000 | |
EXPOSE 5000 | |
EXPOSE 8091 | |
RUN apk update && apk add --no-cache nmap && \ | |
echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \ | |
echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \ | |
apk update && \ | |
apk add --no-cache \ | |
bzip2 \ | |
chromium \ | |
harfbuzz \ | |
"freetype>2.8" \ | |
ttf-freefont \ | |
nss | |
# Install app dependencies | |
COPY package.json ./ | |
#COPY yarn.lock ./ | |
RUN yarn install | |
COPY . . | |
CMD [ "yarn", "start" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const instance = await puppeteer.launch({ | |
headless: true, | |
executablePath: '/usr/bin/chromium-browser', | |
args: [ | |
"--no-sandbox", | |
"--disable-gpu", | |
`--window-size=${config.get('phantom.viewportSize').width},${config.get('phantom.viewportSize.height')}` | |
] | |
}); | |
const page = await instance.newPage(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment