chore: make Docker Compose stack worktree-safe for parallel development#5249
Open
chore: make Docker Compose stack worktree-safe for parallel development#5249
Conversation
- Remove fixed container_name values from all compose files so containers are namespaced by Compose project name - Parameterize host ports (DB_PORT, BACKEND_PORT, FRONTEND_PORT) and backend domain (BACKEND_DOMAIN) with safe defaults in all compose files - Move data-import and disable-users behind a 'setup' profile to avoid stale exited containers on routine docker compose up - Remove data-import from backend depends_on (incompatible with profiles) - Update README and AGENTS.md with profile-aware commands, port variable table, and multi-worktree parallel development workflow example - Add docs/developers/worktree-safe-docker.md tracking document Closes #5237
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the local Docker Compose development stack to support running multiple parallel Git worktrees/checkouts without container-name or host-port collisions (Issue #5237).
Changes:
- Removed hard-coded
container_nameentries so Compose project scoping provides isolation. - Parameterized host port mappings and frontend backend-domain configuration via environment variables with safe defaults.
- Moved one-shot setup services (
data-import,disable-users) behind asetupprofile and updated developer documentation/workflows accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
docker-compose.yml |
Removes fixed container names, parameterizes ports/domain, and profiles setup services to avoid collisions and stale containers. |
docker-compose.static.yml |
Applies the same worktree-safe naming/port changes; parameterizes VITE_BACKEND_DOMAIN build arg; profiles setup services. |
docker-compose.demo.yml |
Applies the same worktree-safe naming/port changes; profiles setup services for demo stack. |
docker-compose.initial.yml |
Applies the same worktree-safe naming/port changes; profiles setup services for initial seed flow. |
backend/ops_api/tests/docker-compose.yml |
Removes fixed container names and parameterizes DB host port for parallel runs. |
backend/data_tools/tests/docker-compose.yml |
Removes fixed container name and parameterizes DB host port (preserving existing non-standard default). |
README.md |
Documents setup-profile workflow and adds guidance for parallel worktrees with COMPOSE_PROJECT_NAME + port vars. |
AGENTS.md |
Updates Docker commands and documents port variables for worktree-safe parallel development. |
docs/developers/worktree-safe-docker.md |
Adds a tracking/plan document describing the approach, variables, and workflows for worktree-safe Compose usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…to CI - Restore container_name: pytest-data-import in backend/ops_api/tests/docker-compose.yml so conftest.py is_loaded() can find the container by name via docker ps - Add --profile setup to .github/actions/run-full-stack/action.yml so E2E tests run with a seeded database - Fix misleading doc comments: setup services run concurrently with backend/frontend, not strictly before them (depends_on was removed); update stale container name reference in worktree-safe-docker.md
weimiao67
approved these changes
Mar 12, 2026
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.
Summary
Closes #5237
Removes host-port collisions and container-name conflicts that occur when running the Docker Compose stack from multiple Git worktrees or parallel checkouts.
Changes
Compose files (all 6)
container_namevalues — Docker Compose now auto-names containers as{project}-{service}-{n}, which is unique per Compose projectDB_PORT(default5432)BACKEND_PORT(default8080)FRONTEND_PORT(default3000)BACKEND_DOMAIN(defaulthttp://localhost:8080) — used byVITE_BACKEND_DOMAIN/REACT_APP_BACKEND_DOMAINMain compose files (
docker-compose.yml,.static.yml,.demo.yml,.initial.yml)data-importanddisable-usersbehind asetupprofile — eliminates stale exited containers on routinedocker compose updata-importfrombackend'sdepends_on— required because a profiled service that isn't activated would otherwise blockbackendfrom startingNew developer workflows
Documentation
README.md— updated Run section with first-run/subsequent-run split; added "Running multiple worktrees in parallel" section with port variable tableAGENTS.md— updated Docker Commands block to reflect profile-aware commands and port variable tabledocs/developers/worktree-safe-docker.md— new tracking document with full plan and completed task checklistNotes
git clone file:///workdirinside a container, but a worktree's.gitis a pointer file rather than a directory, making the clone fail. CI usesactions/checkoutwith a normal clone so it is not affected. This is a separate pre-existing issue.