Skip to content

Commit

Permalink
Containerize puppeteer.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Apr 27, 2024
1 parent 61fb71a commit faece24
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
node_modules
build
docs
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM node:20

# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
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/*

WORKDIR /app

COPY . .

ENV CI=1
ENV NODE_ENV=development

RUN yarn install
RUN yarn build
RUN servebuild 1>/dev/null &

CMD yarn test:puppeteer
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"deploy:staging": "npm run lint && npm run build && firebase hosting:channel:deploy staging --expires 30d",
"deploy:staging2": "npm run lint && npm run build && firebase hosting:channel:deploy staging2 --expires 30d",
"deploy:dev": "npm run lint && npm run build && firebase hosting:channel:deploy dev --expires 30d",
"docker:build": "docker build --platform linux/amd64 --rm -t em-snapshot .",
"docker:run": "docker run em-snapshot",
"lint": "FORCE_COLOR=1 npm-run-all --parallel --aggregate-output lint:*",
"lint:src": "FORCE_COLOR=1 eslint . --cache --rule 'no-console: [2, { allow: [error, info, warn] }]'",
"lint:lockfile": "npx lockfile-lint",
Expand Down

0 comments on commit faece24

Please sign in to comment.