Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(docker): publish no host ports for the built-in MinIO container

Yudhi Armyndharis28d8a4e72a8b
diff --git a/docs/10-devops-infrastructure.md b/docs/10-devops-infrastructure.md
index fa0b98fbb..e6c696be9 100644
--- a/docs/10-devops-infrastructure.md
+++ b/docs/10-devops-infrastructure.md
@@ -447,8 +447,8 @@ LOG_FORMAT=json
# STORAGE_TYPE=s3
# S3_ENDPOINT=http://minio:9000
# S3_BUCKET=openwa
-# S3_ACCESS_KEY_ID=minioadmin
-# S3_SECRET_ACCESS_KEY=minioadmin
+# S3_ACCESS_KEY_ID=your-access-key
+# S3_SECRET_ACCESS_KEY=your-secret-key
# One deployment per bucket and key prefix. S3_KEY_PREFIX (default media/) is the key root: give a
# second deployment with its own database its own bucket or a non-overlapping prefix (neither may
diff --git a/src/config/bootstrap-security.ts b/src/config/bootstrap-security.ts
index e3827b935..75bc7c7da 100644
--- a/src/config/bootstrap-security.ts
+++ b/src/config/bootstrap-security.ts
@@ -217,7 +217,8 @@ export function assertNoDefaultSecretsInProduction(env: SecretCheckEnv): void {
const isWeak = (value?: string): boolean => !value || FORBIDDEN_PROD_SECRETS.has(value.trim().toLowerCase());
const problems: string[] = [];
- // Built-in datastores run on the internal-only Docker network (not published), so their fixed
+ // Built-in datastores run on the internal-only Docker network (the managed container specs in
+ // docker.service.ts publish no host ports), so their fixed
// 'openwa'/'minioadmin' credentials are not internet-reachable — exempt them so selecting the
// built-in option doesn't crash-loop a production boot. The exemption requires BOTH the built-in
// flag AND an internal host: a host-pinned EXTERNAL datastore (even with the built-in flag set) is
diff --git a/src/modules/docker/compose-parity.spec.ts b/src/modules/docker/compose-parity.spec.ts
index 7c783b386..23ded829d 100644
--- a/src/modules/docker/compose-parity.spec.ts
+++ b/src/modules/docker/compose-parity.spec.ts
@@ -475,13 +475,13 @@ describe('DockerService managed specs ↔ docker-compose.yml parity', () => {
}
});
- it('minio: publishes the same localhost-only ports as compose', async () => {
+ it('minio: built-in publishes no host ports, compose keeps its loopback ports', async () => {
+ // The built-in container runs the fixed built-in credentials, which the boot guard exempts only
+ // because nothing outside the internal network can reach it. Compose is the manual path with
+ // operator-set credentials, so it keeps its loopback publish.
const cfg = await capture('minio');
+ expect(cfg.HostConfig.PortBindings).toBeUndefined();
expect(compose.services.minio.ports).toEqual(['127.0.0.1:9000:9000', '127.0.0.1:9001:9001']);
- expect(cfg.HostConfig.PortBindings).toEqual({
- '9000/tcp': [{ HostIp: '127.0.0.1', HostPort: '9000' }],
- '9001/tcp': [{ HostIp: '127.0.0.1', HostPort: '9001' }],
- });
});
});
diff --git a/src/modules/docker/docker.service.ts b/src/modules/docker/docker.service.ts
index 7e78eaf7c..423f3c4db 100644
--- a/src/modules/docker/docker.service.ts
+++ b/src/modules/docker/docker.service.ts
@@ -232,6 +232,10 @@ export class DockerService implements OnModuleInit {
* checkout to support a custom POSTGRES_SCHEMA. The Docker-API path cannot know a host path
* to mount, and the built-in flow always pins POSTGRES_SCHEMA=public, so no init script (or
* POSTGRES_SCHEMA env) is set here.
+ * - Host ports: compose's minio (the manual path, operator-set credentials) publishes
+ * 127.0.0.1:9000/9001. The specs below publish nothing, like postgres and redis: they run the
+ * fixed built-in credentials, which the boot guard exempts only because the container is
+ * reachable on the internal network alone. The app reaches it by its `minio` alias.
* - Resource limits: neither path sets CPU/memory/PID limits on the datastore containers;
* only openwa-api carries mem_limit/pids_limit (in compose).
*/
@@ -244,7 +248,6 @@ export class DockerService implements OnModuleInit {
volumes?: { name: string; path: string }[];
healthcheck?: { test: string[]; interval: number; timeout: number; retries: number };
labels: Record<string, string>;
- ports?: { container: number; host: number }[];
securityOpt: string[];
} | null {
// A container outlives the process that creates it, and after a dashboard save the restart that
@@ -309,10 +312,6 @@ export class DockerService implements OnModuleInit {
`MINIO_ROOT_PASSWORD=${nextBoot('S3_SECRET_ACCESS_KEY') || nextBoot('S3_SECRET_KEY') || 'minioadmin'}`,
],
volumes: [{ name: 'openwa_minio-data', path: '/data' }],
- ports: [
- { container: 9000, host: 9000 },
- { container: 9001, host: 9001 },
- ],
healthcheck: {
test: ['CMD', 'curl', '-f', 'http://localhost:9000/minio/health/live'],
interval: 10000000000,
@@ -397,10 +396,6 @@ export class DockerService implements OnModuleInit {
RestartPolicy: { Name: 'unless-stopped' },
Binds: spec.volumes?.map(v => `${v.name}:${v.path}`),
SecurityOpt: spec.securityOpt,
- PortBindings: spec.ports?.reduce<Record<string, { HostIp: string; HostPort: string }[]>>((acc, p) => {
- acc[`${p.container}/tcp`] = [{ HostIp: '127.0.0.1', HostPort: p.host.toString() }];
- return acc;
- }, {}),
},
Healthcheck: spec.healthcheck
? {