Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(docker): chown only /app/data instead of the whole /app tree (#1056)

Yudhi Armyndharis4987b804a5be
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 208e11bba..44758bf4b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
REST, the WebSocket gateway and the MCP mount all route through, so every surface agrees on what the
credential is. Whitespace is never part of a key, so no legitimate credential changes meaning.
+- **Image builds no longer walk all of `node_modules` to chown it.** The production stage ended with
+ `chown -R openwa:openwa /app`, which touched every installed dependency file — over half an hour on
+ a small VPS, the slowest step of the build — and duplicated their metadata into a new image layer.
+ It was redundant: runtime writes only happen under `/app/data` and `/tmp`, the entrypoint re-chowns
+ `/app/data` at every container start, and the app tree only needs read access. The chown now covers
+ `./data` only, so the step is instant and the layer is gone. (#1045)
+
## [0.12.5] - 2026-08-03
The follow-up to 0.12.4, and the end of the decomposition work. **Nothing here is visible to a user or
diff --git a/Dockerfile b/Dockerfile
index f2e56e049..05711a69f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -151,9 +151,13 @@ COPY --from=builder /app/dist ./dist
# (app.module.ts resolves dashboard/dist relative to dist/). Single container, single port.
COPY --from=builder /app/dashboard/dist ./dashboard/dist
-# Create data directories with correct ownership
-RUN mkdir -p ./data/sessions ./data/media && \
- chown -R openwa:openwa /app
+# Create data directories with correct ownership. Only ./data is chowned, NOT all of /app: the app
+# tree (node_modules, dist) only needs read access, which root-owned files already grant, and the
+# entrypoint re-chowns /app/data at every container start for the mounted-volume case. A full
+# /app chown walks every production dependency file (issue #1045: ~35 minutes on a small VPS) and
+# duplicates their metadata into a new image layer.
+RUN mkdir -p ./data/sessions ./data/media ./data/plugins && \
+ chown -R openwa:openwa ./data
# The non-root openwa user has no home of its own (`useradd -r`, no -m). Chromium resolves the home
# dir from the passwd entry via glib's getpwuid() — it IGNORES $HOME — so it tries to read/write