Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(docker): use the skip-download variable puppeteer reads

Yudhi Armyndharis7ad3785dacdb
diff --git a/Dockerfile b/Dockerfile
index e4217b8fc..ffd403327 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -171,8 +171,9 @@ http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.l
&& apt-get update && apt-get install -y --no-install-recommends postgresql-client-17 \
&& rm -rf /var/lib/apt/lists/*
-# Set Puppeteer to skip automatic download during npm install (we download it explicitly below)
-ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
+# Keep puppeteer's postinstall from downloading a browser (the --ignore-scripts install below
+# already skips it; amd64 downloads its pinned build explicitly further down)
+ENV PUPPETEER_SKIP_DOWNLOAD=true
# Create app user for security. The ids are pinned (997 is what `-r` assigned on both arches) so a
# Kubernetes runAsUser/fsGroup or a `docker run --user` can name the runtime user; the root start
diff --git a/src/modules/docker/compose-parity.spec.ts b/src/modules/docker/compose-parity.spec.ts
index 8d54911c1..fac048b6a 100644
--- a/src/modules/docker/compose-parity.spec.ts
+++ b/src/modules/docker/compose-parity.spec.ts
@@ -359,7 +359,7 @@ describe('DockerService managed specs ↔ docker-compose.yml parity', () => {
// A compose `environment:` entry overrides the image ENV even when it renders BLANK, and the blank
// is then cleared by load-env, so a `- PUPPETEER_EXECUTABLE_PATH=${PUPPETEER_EXECUTABLE_PATH:-}`
// forward deletes the Dockerfile's path inside the container and puppeteer falls back to a
- // bundled Chromium the image deliberately does not ship (PUPPETEER_SKIP_CHROMIUM_DOWNLOAD). The
+ // bundled Chromium the image deliberately does not ship (PUPPETEER_SKIP_DOWNLOAD). The
// forward must therefore carry the image's own value as its default, kept in sync by this test.
it('forwards PUPPETEER_EXECUTABLE_PATH with the Dockerfile default, not blank', () => {
const imageValue = /^ENV PUPPETEER_EXECUTABLE_PATH=(\S+)$/m.exec(
@@ -374,6 +374,21 @@ describe('DockerService managed specs ↔ docker-compose.yml parity', () => {
}
});
+ // puppeteer ignores an env var it does not know, so a misspelled or retired name in the image is
+ // dead config whose comment still claims the effect.
+ it('sets only PUPPETEER_* image ENV names the installed puppeteer reads', () => {
+ const names = [
+ ...readFileSync(join(__dirname, '../../../Dockerfile'), 'utf8').matchAll(/^ENV (PUPPETEER_\w+)=/gm),
+ ].map(match => match[1]);
+ expect(names.length).toBeGreaterThan(0);
+ // A file path, not require.resolve: jest maps `puppeteer` to a mock.
+ const config = readFileSync(
+ join(__dirname, '../../../node_modules/puppeteer/lib/cjs/puppeteer/getConfiguration.js'),
+ 'utf8',
+ );
+ expect(names.filter(name => !config.includes(`'${name}'`))).toEqual([]);
+ });
+
// .env.example documents API_PORT as the host port Docker Compose publishes, and the README quick
// start runs the dev file, so a hardcoded 2785 there ignores the knob when that port is taken.
it.each(['docker-compose.yml', 'docker-compose.dev.yml'])('%s publishes the API on the API_PORT host port', file => {