Repository navigation
fix(make): isolate docker compose project and ports per checkout - #4
Merged
Merged
Conversation
Parallel worktrees shared one compose project and fixed ports, so a second make test reused or collided with another worktree's Postgres. The Makefile now derives the compose project name and dev Postgres/pgweb ports from the checkout path, publishes the test Postgres on a free port chosen by Docker, and prints them (make env). All values stay overridable via env or .env; CI calls go test directly and is unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
make testandmake db-upused one fixed compose project (ai-patterns-go) and fixed host ports (test Postgres 54329, Postgres 5432, pgweb 5050). Parallel worktrees, the normal way agents work on this template, either shared each other's containers or failed with "port is already allocated". The mobile branch hit this on 54339.How
.env(COMPOSE_PROJECT_NAME,POSTGRES_PORT,PGWEB_PORT,TEST_POSTGRES_PORT,DATABASE_URL).make testusesTEST_DATABASE_URLas is when set.make envprints the values, anddb-upandtestprint them too..env.exampleno longer hardcodesDATABASE_URL; make derives it.go testwith its ownTEST_DATABASE_URLand never calls make.Evidence
Run in two worktrees started concurrently: this one and a second worktree at the same commit (later removed). Both ran
GOFLAGS=-count=1 make testat the same time:feat-foundation-6e0df7wt2-409717Both finished in 14 s. Concurrent
make db-up+make migratealso worked: Postgres 25980/25709, pgweb 26980/26709, and migrations applied in both.make cipasses locally in 18.5 s; gofmt and golangci-lint report 0 issues.Merge Danger
Door: two-way. This only changes local tooling.
Blast Radius: local-dev. Existing checkouts get new default ports for the dev database. A
.envthat pinsPOSTGRES_PORT/DATABASE_URLkeeps working. A dev database created under the old shared project is not reused; runmake db-up && make migrateonce, or setCOMPOSE_PROJECT_NAME=ai-patterns-goin.envto keep it.🤖 Generated with Claude Code