From 25d28779c4a8cd5d8dfe6a53123e6a61f3672940 Mon Sep 17 00:00:00 2001 From: "Eric NICOLAS (ccjmne)" Date: Tue, 21 Nov 2023 20:02:04 +0100 Subject: [PATCH] Build for both AMD and ARM architectures Now working off the the node:current-alpine image, see https://stackoverflow.com/a/72291691/2427596 --- .github/workflows/publish-to-ghcr.yml | 1 + Dockerfile | 8 ++++++-- README.md | 2 ++ src/index.js | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-to-ghcr.yml b/.github/workflows/publish-to-ghcr.yml index b15ad75..ef69b93 100644 --- a/.github/workflows/publish-to-ghcr.yml +++ b/.github/workflows/publish-to-ghcr.yml @@ -43,6 +43,7 @@ jobs: with: context: . file: ./Dockerfile + platforms: amd64,arm64 push: true tags: | ghcr.io/${{ github.repository }}:${{ env.TAG_VERSION }} diff --git a/Dockerfile b/Dockerfile index e69d291..f38aaa6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,14 @@ -FROM ghcr.io/puppeteer/puppeteer:latest +# See https://stackoverflow.com/a/72291691/2427596 +FROM node:current-alpine + LABEL org.opencontainers.image.source https://github.com/ccjmne/puppeteer-html2pdf USER root +RUN apk add chromium + # https://github.com/Yelp/dumb-init -RUN apt-get update && apt-get install -y dumb-init +RUN apk update && apk add dumb-init WORKDIR /app ADD . . diff --git a/README.md b/README.md index 3a0daa7..ebcb25a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Technologies used: - [Express](https://expressjs.com/) - [NodeJS](https://nodejs.org/en/) +It offers images for both ARM and AMD architectures. + ## Run it As a webserver, on the port of your choosing. diff --git a/src/index.js b/src/index.js index d233936..f63f4dc 100644 --- a/src/index.js +++ b/src/index.js @@ -33,7 +33,7 @@ function parseRequest(request) { export function use(puppeteer) { function launchBrowser() { return puppeteer.launch({ - executablePath: 'google-chrome-stable', + executablePath: 'chromium-browser', headless: 'new', args: ['--no-sandbox', '--disable-setuid-sandbox'] });