Skip to content

chore(compose): single-source the FDB port numbers (#189) - #194

Open
IG-ABHINAV wants to merge 1 commit into
crazy-goat:masterfrom
IG-ABHINAV:chore/single-source-fdb-ports-189
Open

IG-ABHINAV wants to merge 1 commit into
crazy-goat:masterfrom
IG-ABHINAV:chore/single-source-fdb-ports-189

Conversation

@IG-ABHINAV

Copy link
Copy Markdown

What

Closes the port-number triplication from #189: the five FDB_*_CONTAINER_PORT values in a committed .env are now the only place an FDB port number is written.

How

  • .env (new, committed): the five container ports (4500, 4501, 4502, 4510, 4511) as FDB_*_CONTAINER_PORT — the single source of truth.
  • docker-compose.yml: every hardcoded port literal is gone. FDB_PORT, the ports: mapping target, the mapping default (${FDB_COORD_1_PORT:-${FDB_COORD_1_CONTAINER_PORT}}) and the x-fdb-cluster-file coordinator string all read those variables, so changing one value in .env updates the service env, the host mapping and the cluster string together.
  • bin/host-cluster-file.sh (new): prints the host-side cluster file (127.0.0.1:<mapped port>) from the same values, honouring the FDB_COORD_*_PORT host overrides.
  • tests/Unit/ComposeFdbPortSingleSourceTest.php (new, 5 tests): guards the single source — .env defines each port exactly once, docker-compose.yml contains no port literal, the compose references and the host-cluster script stay in sync.
  • AGENTS.md / CHANGELOG.md: document the new source of truth and the .env vs .env.worktree precedence (exported shell env still wins, matching Docker Compose).

Verification (local)

Check Result
docker compose config -q passes (incl. nested ${VAR:-${OTHER}} interpolation)
vendor/bin/phpunit --testsuite Unit 622 tests, 1215 assertions, 0 failures/errors, 36 env skips
vendor/bin/phpunit --filter ComposeFdbPortSingleSourceTest OK (5 tests, 24 assertions)
vendor/bin/phpstan analyse [OK] No errors
vendor/bin/php-cs-fixer fix --dry-run (new file) Found 0 of 1 files to fix
shellcheck bin/host-cluster-file.sh clean

Ran in a PHP container with the gmp extension (unit tests need ext-gmp for the Tuple cases; without it 19 unrelated Tuple tests error — with it the suite is fully green, so there are no pre-existing failures in scope).

Judgment calls (please flag if you'd prefer otherwise)

  1. .env as the source rather than x-…-port anchors (the alternative in the issue): .env also serves bin/host-cluster-file.sh and any host-side client, which anchors alone would not; .env is not gitignored in this repo (only /.env.worktree is), and the new unit test pins it so it cannot drift. Easy to switch to anchors if you'd rather not commit a .env.
  2. .github/workflows/ci.yml not touched: my tooling cannot push workflow-file changes, so the e2e job still writes its host cluster file inline (ci.yml:185). bin/host-cluster-file.sh builds the identical file from the same source — calling it from the workflow is a one-line follow-up (documented in AGENTS.md). Because of this I could not run the repo's bin/lint.sh end-to-end locally (it needs the repo's pinned toolchain downloads); its individual PHP steps (phpstan, php-cs-fixer) and shellcheck were run and are green.

No integration/e2e stack was started locally (docker compose config -q used for compose validation); a fresh-stack health check needs CI.

The five FDB_*_CONTAINER_PORT values in .env are now the only place a port
number is written. docker-compose.yml references them for each service FDB_PORT,
the host port-mapping target and default, and the coordinator string; the
compose file contains no port literals. bin/host-cluster-file.sh builds the
host-side cluster file from the same values, and ComposeFdbPortSingleSourceTest
fails if a literal returns to docker-compose.yml.

Verified: docker compose config -q, full Unit suite (622 tests / 1215
assertions green, 36 env skips), phpstan clean, php-cs-fixer clean on the new
test, shellcheck clean on the new script.
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.

1 participant