@@ -79,13 +79,14 @@ FROM node:16-bullseye-slim as chromium-downloader
7979# Yeah, downloading Chromium never needs those dependencies below.
8080
8181WORKDIR /app
82+ COPY ./.puppeteerrc.js /app/
8283COPY --from=dep-version-parser /ver/.puppeteer_version /app/.puppeteer_version
8384
8485ARG TARGETPLATFORM
8586ARG USE_CHINA_NPM_REGISTRY=0
8687ARG PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
8788# The official recommended way to use Puppeteer on x86(_64) is to use the bundled Chromium from Puppeteer:
88- # https://github.com/puppeteer/puppeteer #q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy
89+ # https://pptr.dev/faq #q-why-doesnt-puppeteer-vxxx-work-with-chromium-vyyy
8990RUN \
9091 set -ex ; \
9192 if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
9899 yarn add puppeteer@$(cat /app/.puppeteer_version) && \
99100 yarn cache clean ; \
100101 else \
101- mkdir -p /root /.cache/puppeteer ; \
102+ mkdir -p /app/node_modules /.cache/puppeteer ; \
102103 fi;
103104
104105# ---------------------------------------------------------------------------------------------------------------------
@@ -115,11 +116,11 @@ WORKDIR /app
115116# install deps first to avoid cache miss or disturbing buildkit to build concurrently
116117ARG TARGETPLATFORM
117118ARG PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
118- # https://github.com/puppeteer/puppeteer/blob/main/docs/ troubleshooting.md #chrome-headless-doesnt-launch-on-unix
119+ # https://pptr.dev/ troubleshooting#chrome-headless-doesnt-launch-on-unix
119120# https://github.com/puppeteer/puppeteer/issues/7822
120121# https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html#noteworthy-obsolete-packages
121122# The official recommended way to use Puppeteer on arm/arm64 is to install Chromium from the distribution repositories:
122- # https://github.com/puppeteer/puppeteer/blob/94cb08c85955c0688d12b6ed10e61a4581a01280/ src/node/BrowserFetcher.ts#L116-L119
123+ # https://github.com/puppeteer/puppeteer/blob/07391bbf5feaf85c191e1aa8aa78138dce84008d/packages/puppeteer-core/ src/node/BrowserFetcher.ts#L128-L131
123124RUN \
124125 set -ex && \
125126 apt-get update && \
@@ -143,14 +144,14 @@ RUN \
143144 fi; \
144145 rm -rf /var/lib/apt/lists/*
145146
146- COPY --from=chromium-downloader /root/ .cache/puppeteer /root /.cache/puppeteer
147+ COPY --from=chromium-downloader /app/node_modules/ .cache/puppeteer /app/node_modules /.cache/puppeteer
147148
148149# if grep matches nothing then it will exit with 1, thus, we cannot `set -e` here
149150RUN \
150151 set -x && \
151152 if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = 0 ] && [ "$TARGETPLATFORM" = 'linux/amd64' ]; then \
152153 echo 'Verifying Chromium installation...' && \
153- ldd $(find /root/ .cache/puppeteer/ -name chrome) | grep "not found" ; \
154+ ldd $(find /app/node_modules/ .cache/puppeteer/ -name chrome -type f ) | grep "not found" ; \
154155 if [ "$?" = 0 ]; then \
155156 echo "!!! Chromium has unmet shared libs !!!" && \
156157 exit 1 ; \
@@ -177,7 +178,7 @@ CMD ["npm", "run", "start"]
177178# apt-file \
178179# && \
179180# apt-file update && \
180- # ldd $(find /app/node_modules/puppeteer/ -name chrome) | grep -Po "\S+(?= => not found)" | \
181+ # ldd $(find /app/node_modules/.cache/ puppeteer/ -name chrome -type f ) | grep -Po "\S+(?= => not found)" | \
181182# sed 's/\./\\./g' | awk '{print $1"$"}' | apt-file search -xlf - | grep ^lib | \
182183# xargs -d '\n' -- \
183184# apt-get install -yq --no-install-recommends \
0 commit comments