Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(compose): stop the minio service from starting without a secret
Yudhi Armyndharis11637b24cc68
diff --git a/README.md b/README.mdindex 1cff21d40..97fe268df 100644--- a/README.md+++ b/README.md@@ -279,8 +279,14 @@ docker compose --profile full up -dA profile only starts the container; OpenWA keeps using SQLite and local storage until it is toldto use the new service. The simplest route is **Dashboard > Infrastructure**: pick the built-in-option, save, and restart from there, and OpenWA starts the container itself. To use a profile-directly, set these in the `.env` next to `docker-compose.yml` first:+option, save, and restart from there, and OpenWA starts the container itself. The built-in storage+option creates its own `openwa-minio` container, so do not also start the `minio` or `full` profile+for it. The same goes for built-in PostgreSQL and Redis: each built-in option creates its own+container, and the compose profiles are for the manual `.env` route below. The compose `minio`+service starts only once `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` are set in the `.env` next to+`docker-compose.yml`; if it was already started without them, run `docker rm -f openwa-minio` before+you enable built-in storage. To use a profile directly, set these in the `.env` next to+`docker-compose.yml` first:- PostgreSQL: `DATABASE_TYPE=postgres`, `DATABASE_HOST=postgres`, `DATABASE_USERNAME=openwa`,`DATABASE_PASSWORD=<strong password>`@@ -288,8 +294,8 @@ directly, set these in the `.env` next to `docker-compose.yml` first:- MinIO: `STORAGE_TYPE=s3`, `S3_ENDPOINT=http://minio:9000`, `S3_ACCESS_KEY_ID=<user>`,`S3_SECRET_ACCESS_KEY=<strong password>`-PostgreSQL and MinIO refuse to initialize with an empty password, and a production boot rejects-default credentials such as `openwa` or `minioadmin`.+PostgreSQL refuses to initialize a new volume with an empty password, MinIO refuses to start+without one, and a production boot rejects default credentials such as `openwa` or `minioadmin`.> The dashboard is bundled into the API image and served by NestJS on the API port, so it> needs no profile — it is always available wherever `openwa-api` runs. For TLS/public exposure,diff --git a/docker-compose.yml b/docker-compose.ymlindex a278c47a0..e4da223e8 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -501,12 +501,15 @@ services:- 'no-new-privileges:true'command: server /data --console-address ":9001"environment:- # M16: no committed default creds. MinIO refuses to start with empty root creds- # (clear fail-fast); the app's production boot guard rejects empty/placeholder secrets.+ # No committed default credentials. With both left empty the server would start on its own+ # built-in default pair, so the password falls back to a placeholder shorter than the+ # 8-character minimum: every combination without a real secret stops at startup with a fatal+ # credential error (with a user set and no secret it reads "Invalid credentials"). The user+ # default stays empty on purpose: a non-empty placeholder would be a valid access key.# Canonical names, matching what the app/dashboard read (legacy S3_ACCESS_KEY/S3_SECRET_KEY# still accepted as a fallback so older .env files keep working).MINIO_ROOT_USER: ${S3_ACCESS_KEY_ID:-${S3_ACCESS_KEY:-}}- MINIO_ROOT_PASSWORD: ${S3_SECRET_ACCESS_KEY:-${S3_SECRET_KEY:-}}+ MINIO_ROOT_PASSWORD: ${S3_SECRET_ACCESS_KEY:-${S3_SECRET_KEY:-unset}}volumes:- minio-data:/dataports:diff --git a/docs/08-development-guidelines.md b/docs/08-development-guidelines.mdindex 71b72551c..5023ed2c5 100644--- a/docs/08-development-guidelines.md+++ b/docs/08-development-guidelines.md@@ -657,7 +657,12 @@ docker compose --profile full up -dA profile only starts the extra containers. Point OpenWA at them first, from Dashboard >Infrastructure or with the `.env` variables listed under Production Deployment in the README;-otherwise it stays on SQLite and local storage.+otherwise it stays on SQLite and local storage. The dashboard's built-in storage option creates its+own `openwa-minio` container, so do not also start the `minio` or `full` profile for it. The same goes+for built-in PostgreSQL and Redis: each built-in option creates its own container, and the compose+profiles are for the manual `.env` route. The compose `minio` service starts only once+`S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` are set in the `.env` next to `docker-compose.yml`; if it+was already started without them, run `docker rm -f openwa-minio` before you enable built-in storage.### VS Code Extensionsdiff --git a/src/modules/docker/compose-parity.spec.ts b/src/modules/docker/compose-parity.spec.tsindex 9ae204169..7c783b386 100644--- a/src/modules/docker/compose-parity.spec.ts+++ b/src/modules/docker/compose-parity.spec.ts@@ -399,12 +399,38 @@ describe('DockerService managed specs ↔ docker-compose.yml parity', () => {const cfg = await capture('minio');expect(cfg.Env).toEqual(['MINIO_ROOT_USER=minioadmin', 'MINIO_ROOT_PASSWORD=minioadmin']);const env = compose.services.minio.environment!;- // Compose (manual path) deliberately ships no default and fails fast on empty creds; the- // orchestrated path provisions the built-in default instead (see the getContainerSpec docblock).+ // Compose (manual path) deliberately ships no default credentials; the orchestrated path+ // provisions the built-in default instead (see the getContainerSpec docblock). The user default+ // stays empty: a non-empty placeholder would be a valid access key paired with a real password.expect(env.MINIO_ROOT_USER).toBe('${S3_ACCESS_KEY_ID:-${S3_ACCESS_KEY:-}}');- expect(env.MINIO_ROOT_PASSWORD).toBe('${S3_SECRET_ACCESS_KEY:-${S3_SECRET_KEY:-}}');+ expect(env.MINIO_ROOT_PASSWORD).toBe('${S3_SECRET_ACCESS_KEY:-${S3_SECRET_KEY:-unset}}');});+ it('minio: compose falls back to a password too short to be valid, so no secret means no start', () => {+ // Both credentials empty would start the server on its built-in default pair. A placeholder+ // under the 8-character minimum stops it instead; a longer one would become a working default.+ const placeholder = /:-([^:}]*)}}$/.exec(compose.services.minio.environment!.MINIO_ROOT_PASSWORD)?.[1];+ expect(placeholder).toBeTruthy();+ expect(placeholder!.length).toBeLessThan(8);+ });++ it.each(['README.md', 'docs/08-development-guidelines.md'])(+ '%s tells a fresh install not to pair the minio profile with the dashboard built-in storage',+ file => {+ // The dashboard route writes its credentials to data/.env.generated, which compose never reads,+ // so a compose minio started next to it has no password and never comes up. startService then+ // finds that container by its label and only restarts it, so the built-in option cannot recover.+ const text = readFileSync(join(__dirname, '../../..', file), 'utf8').replace(/\s+/g, ' ');+ expect(text).toContain('do not also start the `minio` or `full` profile');+ expect(text).toContain('docker rm -f openwa-minio');+ // Built-in PostgreSQL and Redis also create their own containers. The compose postgres service+ // refuses to initialize without DATABASE_PASSWORD, and startService would only restart it, so+ // the dashboard route must not be told to start any profile.+ expect(text).toContain('each built-in option creates its own container');+ expect(text).not.toContain('--profile postgres --profile redis');+ },+ );+it('minio: prefers the canonical S3 credential env vars, then the legacy ones', async () => {process.env.S3_ACCESS_KEY = 'legacy-user';process.env.S3_SECRET_KEY = 'legacy-secret';diff --git a/src/modules/docker/docker.service.ts b/src/modules/docker/docker.service.tsindex 6221ff1c0..7e78eaf7c 100644--- a/src/modules/docker/docker.service.ts+++ b/src/modules/docker/docker.service.ts@@ -222,7 +222,8 @@ export class DockerService implements OnModuleInit {** Deliberate differences from the compose services — do not "fix" these:* - Credentials: the compose services are the MANUAL operator path and deliberately ship no- * default secret (empty POSTGRES_PASSWORD / MINIO_ROOT_* fail fast on boot). The specs below+ * default secret (an empty POSTGRES_PASSWORD fails when the volume is first initialized; a+ * MINIO_ROOT_PASSWORD left on its sub-minimum placeholder fails at every start). The specs below* are the dashboard built-in path: they provision the fixed built-in credentials* (openwa/openwa, minioadmin/minioadmin) that infra-config.controller writes to data/.env.generated* and that the production boot guard (bootstrap-security.ts) exempts only while the