Decouple in-container DB_PORT from host-side env (BS#959)#963
Merged
Conversation
The ci-profile `backend` service was the only consumer with `DB_PORT=${DB_PORT:-5432}` — every other service (`ci-db-init`, `auth`, `e2e-*`, `etl-db-init`) already hardcodes `5432`. When a stray `.env` has `DB_PORT=5436` (the dev profile default for the host-port mapping), the env substitution leaks into the backend container's `DB_PORT` and breaks its in-network connection to `ci-db`, which still listens on `5432`.
Same shape as the closed BS#413 fix for `AUTH_PORT`. Cost on the BS#955 repro work was several rounds of chasing a "Invalid argument" / 503 healthcheck before the cause surfaced.
Pinned by a new parameterized source-grep test that covers all 8 consumer services so the same regression in a future service surfaces immediately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #959.
Summary
DB_PORT=5432in the ci-profilebackendservice env indev_env/docker-compose.yml— matches the convention already in place on every other consumer service.tests/unit/scripts/docker-compose-db-port.test.ts(parameterized over 8 services) to pin the invariant going forward.Why
The
backendservice was the only consumer withDB_PORT=${DB_PORT:-5432}. Every other consumer (db-init,ci-db-init,auth,e2e-db-init,e2e-auth,e2e-backend,etl-db-init) hardcodes5432. TheDB_PORTenv var has two distinct uses indocker-compose.yml:db.ports: '${DB_PORT:-5432}:5432'5432to whatever host port the user wantsbackend.environment: DB_PORT=…5432because that's what the postgres image listens onConflating them — writing
DB_PORT=${DB_PORT:-5432}in the consumer's env — lets a stray.envvalue leak through. The dev profile defaultsDB_PORT=5436for the host mapping; copying that.envinto a ci-profile setup makes the backend container try to dialci-db:5436, which fails becauseci-dbstill listens on5432inside the docker network. The visible symptom wasInvalid argument/ 503 from the backend healthcheck onnpm run ci:testmock.Same shape as the closed #413 fix for
AUTH_PORT.Scope
One line changed in
dev_env/docker-compose.yml. The other host-port-mapping vars (DB_PORT,CI_DB_PORT,E2E_DB_PORT,ETL_PG_PORT) are unchanged — those legitimately need env substitution so different worktrees can run on different host ports.The new test covers all 8 consumer services, not just
backend, so a future regression elsewhere fails CI before reaching merge.Test plan
npx jest --testPathPatterns docker-compose-db-port— 8/8 pass.npm run test:unit) — 1984/1984 pass..envthat does not setDB_PORT(the default; this is what GHA does today).npm run ci:testmockwith.envcontainingDB_PORT=5436no longer breaks.Related
AUTH_PORT.