refactor(compose): make app/db ports configurable via DB_PORT and SERVER_PORT

Replace hardcoded port literals with env-driven variables so a single change
in .env reconfigures the full stack consistently. Defaults are unchanged
(DB 5432, app 8765), so existing setups need no .env changes.

- DB_PORT (default 5432): drives the db host<->container port mapping,
  Postgres PGPORT (so it listens on the chosen port), and the app's
  DATABASE_PORT connection setting. Lets deployers avoid a host port conflict
  (e.g. another local Postgres) by setting DB_PORT once.
- SERVER_PORT (default 8765): drives the app host<->container mapping, the
  SERVER_PORT the app listens on, and the healthcheck target URL.
- Applied to both the base (docker-compose.yml) and the dev override
  (docker-compose.dev.yml, tests service) so dev and prod stay in sync.
This commit is contained in:
2026-07-29 16:11:01 -04:00
parent 1129fcae6f
commit de8f71b2be
2 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ services:
environment:
# Database Configuration
DATABASE_HOST: db
DATABASE_PORT: "5432"
DATABASE_PORT: ${DB_PORT:-5432}
DATABASE_USER: postgres
DATABASE_PASSWORD: ${DBPASS}
DATABASE_NAME: bookhoard
@@ -31,7 +31,7 @@ services:
# Application Configuration
JWT_SECRET: ${JWT_SECRET}
SERVER_PORT: "8765"
SERVER_PORT: ${SERVER_PORT:-8765}
# Test Configuration
TEST_MODE: "true"