fix(ci): drop postgres service host-port mapping to end 5432 collision (#174) #177

Merged
claude-bot merged 1 commit from fix/174-ci-postgres-host-port into main 2026-07-16 04:19:42 +00:00
Contributor

Root cause (from the runner log for the failing push run)

docker run image=postgres:16 ... network="WORKFLOW-..."
failed to start container: ... Bind for 0.0.0.0:5432 failed: port is already allocated

The backend job's postgres:16 service published ports: - 5432:5432, binding port 5432 on the runner host. That host already runs other Postgres containers on 5432, so the service container failed to start before any test ran — a fast (~10s) job failure. Because host-port availability is a race, it looked like intermittent "push fails, PR passes" flakiness (#174); it was really whichever run happened to hit an already-bound 5432.

Fix

Remove the host-port mapping. It was unnecessary — the job connects to the DB by its network alias (postgres:5432, via DATABASE_URL/TEST_DATABASE_URL), not via the host, exactly as the job's own comment already stated ("the ports: mapping binds the runner host, which the job container cannot see"). Dropping it eliminates the collision entirely, for every event type.

Nothing else changes: the three DB URLs still target @postgres:5432, and the service keeps its pg_isready healthcheck.

Validation

  • ci.yml parses as valid YAML; 5432:5432 gone; DB URLs still use the postgres service alias.
  • This PR's own backend job exercises the change (migrations + full pytest against the service with no host binding).
  • Post-merge, the pushmain run is the real confirmation that the collision is gone; I'll verify it before closing #174.

Refs #174

🤖 Generated with Claude Code

## Root cause (from the runner log for the failing push run) ``` docker run image=postgres:16 ... network="WORKFLOW-..." failed to start container: ... Bind for 0.0.0.0:5432 failed: port is already allocated ``` The `backend` job's `postgres:16` service published **`ports: - 5432:5432`**, binding **port 5432 on the runner host**. That host already runs other Postgres containers on 5432, so the service container **failed to start before any test ran** — a fast (~10s) job failure. Because host-port availability is a race, it looked like intermittent "push fails, PR passes" flakiness (#174); it was really *whichever run happened to hit an already-bound 5432*. ## Fix Remove the host-port mapping. It was **unnecessary** — the job connects to the DB by its **network alias** (`postgres:5432`, via `DATABASE_URL`/`TEST_DATABASE_URL`), not via the host, exactly as the job's own comment already stated ("the ports: mapping binds the runner host, which the job container cannot see"). Dropping it eliminates the collision entirely, for every event type. Nothing else changes: the three DB URLs still target `@postgres:5432`, and the service keeps its `pg_isready` healthcheck. ## Validation - `ci.yml` parses as valid YAML; `5432:5432` gone; DB URLs still use the `postgres` service alias. - This PR's own `backend` job exercises the change (migrations + full pytest against the service with no host binding). - Post-merge, the `push`→`main` run is the real confirmation that the collision is gone; I'll verify it before closing #174. Refs #174 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(ci): drop postgres service host-port mapping to end 5432 collision (#174)
All checks were successful
CI / Frontend tests, audit, and build (pull_request) Successful in 1m23s
CI / Bot tests and audit (pull_request) Successful in 2m14s
CI / Backend lint (ruff) (pull_request) Successful in 2m14s
CI / Backend migration, tests, and audit (pull_request) Successful in 3m48s
CI / Docker image build (pull_request) Successful in 3m52s
e096e9246f
The backend job's postgres:16 service published `5432:5432` on the runner
host. The runner host already has other Postgres containers bound to 5432,
so the service container failed to start before any test ran:

    Bind for 0.0.0.0:5432 failed: port is already allocated

which surfaced as a fast (~10s) job failure. The mapping is unnecessary:
the job connects to the DB by its network alias (postgres:5432, via
DATABASE_URL), not the host — as the job's own comment already noted.
Removing the host binding eliminates the collision.

Root cause of #174 (push-to-main runs failing while PR/dispatch passed was
a timing coincidence of which runs hit an already-bound host 5432).

Refs #174
claude-bot scheduled this pull request to auto merge when all checks succeed 2026-07-16 04:15:35 +00:00
claude-bot deleted branch fix/174-ci-postgres-host-port 2026-07-16 04:19:43 +00:00
Sign in to join this conversation.
No description provided.