Skip to content

fix(compose): use DB_USER consistently — DB_USERNAME silently dropped operator overrides#142

Merged
CryptoJones merged 1 commit into
masterfrom
fix/docker-compose-db-user-name
May 19, 2026
Merged

fix(compose): use DB_USER consistently — DB_USERNAME silently dropped operator overrides#142
CryptoJones merged 1 commit into
masterfrom
fix/docker-compose-db-user-name

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #141.

Summary

app/config/env.js reads process.env.DB_USER and .env.example documents DB_USER=timetracker. But docker-compose.yml and two README sections referenced DB_USERNAME. The mismatch was silent on defaults (both sides fall back to "timetracker"), but meant an operator who set DB_USER=foo in their .env got that value silently dropped by compose's ${DB_USERNAME:-timetracker} interpolation — both Postgres and the app ended up on the default user, not the configured one.

Replace every DB_USERNAME reference with DB_USER:

  • docker-compose.yml — 5 occurrences (postgres POSTGRES_USER, pg_isready healthcheck, PGUSER on setup service, env passthrough on migrate + api)
  • tests/integration/README.md — 1 occurrence in the env-var export example
  • README.md — 1 occurrence in the integration-test quickstart

Backward-compat note: anyone with an existing .env that set the undocumented DB_USERNAME will need to rename it to DB_USER. The default-user path is unchanged.

Test plan

  • npm run lint — clean
  • npm test — 515 passed, 15 skipped (no source code touched, so no test count change)
  • grep -rEn 'DB_USERNAME' . --include='*.yml' --include='*.md' returns empty across tracked files

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

… operator overrides

`app/config/env.js` reads `process.env.DB_USER` (and `.env.example`
documents it). But `docker-compose.yml` and two README sections
referenced `DB_USERNAME`. The mismatch was silent and harmless on
defaults — both compose interpolation and the container's app fell
back to `"timetracker"` — but it meant an operator who set
`DB_USER=foo` in their `.env` got that value SILENTLY DROPPED by
docker-compose's `${DB_USERNAME:-timetracker}` interpolation, and
both Postgres and the app ended up on the default user instead.
The connection still worked (matching by coincidence), but the
operator's stated config never reached the container.

Replace every `DB_USERNAME` reference with `DB_USER`:

  - docker-compose.yml (5 occurrences): POSTGRES_USER, the
    pg_isready healthcheck, PGUSER for the setup service, and
    the env passthroughs on the migrate + api services.
  - tests/integration/README.md (1 occurrence): the env-var
    export example in the manual integration-test recipe.
  - README.md (1 occurrence): the same env-var export in the
    quickstart for running integration tests.

Backward-compat note: anyone with an existing `.env` that set the
undocumented `DB_USERNAME` variable will need to rename it to
`DB_USER`. The CI workflow already uses `DB_USER` and continues to
work unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit f1b6109 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the fix/docker-compose-db-user-name branch May 19, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compose: DB_USERNAME != DB_USER — operator overrides silently dropped

1 participant