Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
build: pin base image and dependencies, ship backup scripts in the image
Yudhi Armyndharis0972ad703bfc
diff --git a/Dockerfile b/Dockerfileindex 37b105ef8..53dd75c56 100644--- a/Dockerfile+++ b/Dockerfile@@ -9,7 +9,10 @@# minifier) optional dependency fails to install ("Cannot find module lightningcss.linux-arm64-gnu.node").# The per-arch runtime deps are installed natively in the target-platform production stage below.# NOTE: $BUILDPLATFORM requires BuildKit (CI uses buildx; modern `docker build`/compose default to it).-FROM --platform=$BUILDPLATFORM docker.io/node:22-slim AS builder+# The digest pins the multi-arch node:22-slim index, so every build starts from the same immutable+# base; dependabot's docker ecosystem proposes the new digest when the tag moves. Update tag and+# digest together.+FROM --platform=$BUILDPLATFORM docker.io/node:22-slim@sha256:d649c27dae7ba0137b3cef5dd75baa422c08dc3d9e3fc0c23dfb172dc3cc6436 AS builderWORKDIR /app@@ -52,7 +55,8 @@ COPY . .RUN npm run build && npm run dashboard:ci -- --include=dev && npm run dashboard:build && rm -f dist/*.tsbuildinfo# ===== Stage 2: Production =====-FROM docker.io/node:22-slim AS production+# Same digest-pinned node:22-slim base as the builder stage.+FROM docker.io/node:22-slim@sha256:d649c27dae7ba0137b3cef5dd75baa422c08dc3d9e3fc0c23dfb172dc3cc6436 AS production# Chrome for Testing has no linux-arm64 build, and Puppeteer's chromium snapshot# is x86_64-only on Linux too. So: amd64 uses Chrome for Testing (downloaded below)@@ -143,8 +147,9 @@ RUN npm ci --omit=dev \# what the release image scan reports. node:22-slim currently ships npm 10.9.8, whose bundle# carries a critical node-tar advisory plus sigstore/picomatch ones; npm 12 fixes all three.# Deliberately AFTER `npm ci`, so the application tree is still resolved by the npm the lockfile-# was generated with and only the global CLI is swapped.-RUN npm install -g npm@12 && npm cache clean --force+# was generated with and only the global CLI is swapped. Pinned to the exact patch release —+# a floating npm@12 would make the image's bundled npm tree depend on when the build happened.+RUN npm install -g [email protected] && npm cache clean --force# amd64: download Chrome for Testing via Puppeteer and symlink it.# arm64: use Debian's chromium installed above (CfT has no linux-arm64 build).@@ -187,6 +192,13 @@ ENV HOME=/app/dataENV XDG_CONFIG_HOME=/tmp/.configENV XDG_CACHE_HOME=/tmp/.cache+# Operator backup/restore scripts. docs/11-operational-runbooks.md drives them in-container+# (`docker exec` against the named-volume mount at /app/data), and the sqlite3 CLI installed above+# is there for backup.sh's online-consistent snapshots — but the scripts themselves were never+# copied into the image. lib-env.sh is sourced by both, never executed. backup.sh/restore.sh carry+# the exec bit in the repo and COPY preserves it, so no chmod is needed.+COPY scripts/backup.sh scripts/restore.sh scripts/lib-env.sh ./scripts/+# Copy entrypoint: runs as root to fix named-volume ownership, then drops to openwa via gosuCOPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.shRUN chmod +x /usr/local/bin/docker-entrypoint.shdiff --git a/dashboard/package-lock.json b/dashboard/package-lock.jsonindex dd3011472..e704855be 100644--- a/dashboard/package-lock.json+++ b/dashboard/package-lock.json@@ -28,7 +28,7 @@"@eslint/js": "^10.0.1","@testing-library/dom": "^10.4.1","@testing-library/react": "^16.3.2",- "@types/node": "^26.1.2",+ "@types/node": "^22","@types/react": "^19.2.18","@types/react-dom": "^19.2.4","@vitejs/plugin-react": "^6.0.5",@@ -1244,13 +1244,13 @@"license": "MIT"},"node_modules/@types/node": {- "version": "26.1.2",- "resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.2.tgz",- "integrity": "sha512-Vu4a5UFA9rIIFJ7rB/Vaafh9lrCQszopTCx6KjFboXTGQbPNasehVR5TEiithSDGyd1DEiUByggTZsg8jukeIg==",+ "version": "22.20.1",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz",+ "integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==","dev": true,"license": "MIT","dependencies": {- "undici-types": "~8.3.0"+ "undici-types": "~6.21.0"}},"node_modules/@types/react": {@@ -3722,9 +3722,9 @@}},"node_modules/undici-types": {- "version": "8.3.0",- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",- "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",+ "version": "6.21.0",+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==","dev": true,"license": "MIT"},diff --git a/dashboard/package.json b/dashboard/package.jsonindex a773e155b..2f738a285 100644--- a/dashboard/package.json+++ b/dashboard/package.json@@ -36,7 +36,7 @@"@eslint/js": "^10.0.1","@testing-library/dom": "^10.4.1","@testing-library/react": "^16.3.2",- "@types/node": "^26.1.2",+ "@types/node": "^22","@types/react": "^19.2.18","@types/react-dom": "^19.2.4","@vitejs/plugin-react": "^6.0.5",diff --git a/package-lock.json b/package-lock.jsonindex 5950e7390..8f517f48b 100644--- a/package-lock.json+++ b/package-lock.json@@ -49,7 +49,7 @@"tar-stream": "^3.2.0","typeorm": "^1.1.0","undici": "^8.10.0",- "whatsapp-web.js": "^1.34.7",+ "whatsapp-web.js": "1.34.7","zod": "^4.4.3"},"devDependencies": {@@ -62,7 +62,7 @@"@types/express": "^5.0.0","@types/jest": "^30.0.0","@types/multer": "^2.2.0",- "@types/node": "^26.1.2",+ "@types/node": "^22","@types/qrcode": "^1.5.5","@types/supertest": "^7.2.1","@types/tar-stream": "^3.1.4",@@ -4504,13 +4504,13 @@}},"node_modules/@types/node": {- "version": "26.1.2",- "resolved": "https://registry.npmjs.org/@types/node/-/node-26.1.2.tgz",- "integrity": "sha512-Vu4a5UFA9rIIFJ7rB/Vaafh9lrCQszopTCx6KjFboXTGQbPNasehVR5TEiithSDGyd1DEiUByggTZsg8jukeIg==",+ "version": "22.20.1",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz",+ "integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==","license": "MIT","peer": true,"dependencies": {- "undici-types": "~8.3.0"+ "undici-types": "~6.21.0"}},"node_modules/@types/qrcode": {@@ -14414,9 +14414,9 @@}},"node_modules/undici-types": {- "version": "8.3.0",- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",- "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",+ "version": "6.21.0",+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",+ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==","license": "MIT"},"node_modules/universalify": {diff --git a/package.json b/package.jsonindex f17d7527a..38e3a5356 100644--- a/package.json+++ b/package.json@@ -104,7 +104,7 @@"tar-stream": "^3.2.0","typeorm": "^1.1.0","undici": "^8.10.0",- "whatsapp-web.js": "^1.34.7",+ "whatsapp-web.js": "1.34.7","zod": "^4.4.3"},"devDependencies": {@@ -117,7 +117,7 @@"@types/express": "^5.0.0","@types/jest": "^30.0.0","@types/multer": "^2.2.0",- "@types/node": "^26.1.2",+ "@types/node": "^22","@types/qrcode": "^1.5.5","@types/supertest": "^7.2.1","@types/tar-stream": "^3.1.4",diff --git a/scripts/backup.sh b/scripts/backup.shindex 9e07cde1b..cf3b023c8 100755--- a/scripts/backup.sh+++ b/scripts/backup.sh@@ -123,8 +123,9 @@ if [ "$DATABASE_TYPE" = "postgres" ]; thenlog "ERROR: DATABASE_TYPE=postgres but pg_dump is not installed"exit 1fi- if [ -n "${DATABASE_URL:-}" ]; then- pg_dump "$DATABASE_URL" >"$STAGE/database.sql"+ DATABASE_URL_RESOLVED="$(openwa_resolve DATABASE_URL '')"+ if [ -n "$DATABASE_URL_RESOLVED" ]; then+ pg_dump "$DATABASE_URL_RESOLVED" >"$STAGE/database.sql"else# Same layered resolution as the paths above: a dashboard-provisioned Postgres keeps its# connection details in <data dir>/.env.generated, never in the operator's shell.diff --git a/scripts/check-dockerignore.mjs b/scripts/check-dockerignore.mjsindex 4d65246de..463af7a29 100644--- a/scripts/check-dockerignore.mjs+++ b/scripts/check-dockerignore.mjs@@ -147,6 +147,9 @@ const mustKeep = ['scripts/patch-wwebjs-status.js','scripts/patch-wwebjs-ready-sync.js','scripts/wwebjs-201832.patch',+ 'scripts/backup.sh',+ 'scripts/restore.sh',+ 'scripts/lib-env.sh','docker-entrypoint.sh','docs/01-project-overview.md',];diff --git a/scripts/postgres-init-schema.sh b/scripts/postgres-init-schema.shindex 2cb94688f..c957bb828 100755--- a/scripts/postgres-init-schema.sh+++ b/scripts/postgres-init-schema.sh@@ -23,6 +23,21 @@ if [ -z "$schema" ] || [ "$schema" = "public" ]; thenexit 0fi+# The value is interpolated into the CREATE SCHEMA / SET search_path statements below, so apply+# the same boot-time validation the app does (src/config/env.validation.ts): a plain, non-reserved+# Postgres identifier or nothing. Fail fast here rather than let a typo reach the SQL.+identifier_re='^[A-Za-z_][A-Za-z0-9_]{0,62}$'+if ! [[ "$schema" =~ $identifier_re ]]; then+ echo "postgres-init-schema: ERROR: POSTGRES_SCHEMA must be a valid Postgres identifier (a letter or underscore, then letters/digits/underscores, max 63 chars; got '${schema}')." >&2+ exit 1+fi+case "$schema" in+ [pP][gG]_*)+ echo "postgres-init-schema: ERROR: POSTGRES_SCHEMA must not use the reserved \"pg_\" prefix (got '${schema}')." >&2+ exit 1+ ;;+esac+echo "postgres-init-schema: creating schema '${schema}' and setting default search_path."# The postgres image exports POSTGRES_USER + POSTGRES_DB for docker-entrypoint-initdb.d