Skip to content

Make the Compose stack's ports configurable - #26

Merged
slominskir merged 1 commit into
integration-testsfrom
configurable-ports
Oct 1, 2026
Merged

slominskir merged 1 commit into
integration-testsfrom
configurable-ports

Conversation

@slominskir-coding-agent

Copy link
Copy Markdown
Contributor

Builds on #24, and targets its branch so the diff shows only this change. When #24 is merged and its branch deleted, GitHub retargets this PR to main.

Problem

Two copies of the Compose stack, or adm and another project's containers, couldn't run at once on one machine:

  • Fixed host ports: every published port was fixed, so adm's Keycloak on 8081 clashed with another project's Keycloak on the agent VM.
  • Fixed container names: adm-oracle and the others (oracle, keycloak and sshd in deps.yaml), so a second copy, such as a sister agent's worktree, collided even on other ports.

What changed

  • Ports: each published port comes from a variable, defaulting to the port used before, so nothing changes unless you set one. Compose reads them from the environment or from .env:
Variable Default
ADM_HTTPS_PORT 8443
ADM_HTTP_PORT 8080
ADM_MANAGEMENT_PORT 9990
ADM_KEYCLOAK_PORT 8081
ADM_KEYCLOAK_MANAGEMENT_PORT 9991
ADM_ORACLE_PORT 1521
ADM_ORACLE_EM_PORT 5500
ADM_SSHD_PORT 1234
  • URLs follow the ports: Keycloak's KC_FRONTEND_URL and KC_REDIRECT_URIS, and the app's KEYCLOAK_FRONTEND_SERVER_URL and FRONTEND_SERVER_URL, use ADM_KEYCLOAK_PORT and ADM_HTTPS_PORT. Logins and token issuers therefore match the ports in use. The app's values were Dockerfile ENVs; Compose now sets them.
  • No more container_name: Compose names containers, the network and built images after the project directory: adm-oracle-1, adm-adm-1 and so on. A copy in another directory, such as a git worktree, gets its own. Commands like docker exec -it adm-oracle ... need the new names. The devcontainer's dev.yaml keeps its own names.
  • Integration tests use the same ports: integrationTest passes the ADM_* variables from .env to the tests, with the environment taking precedence, and the tests build their default URLs from ADM_HTTPS_PORT and ADM_KEYCLOAK_PORT.
  • README: a Ports section lists the variables and gives an example .env for a second copy.

The demo data's local-dev env still deploys to localhost:1234, for a Wildfly run outside Docker. The README notes this next to ADM_SSHD_PORT.

Checks

On the agent VM:

  • docker compose -f build.yaml config with the README's example .env publishes only the 1xxxx ports, and the URLs above use 18081 and 18443.
  • Two stacks at once: I ran the default stack in ~/adm and a second copy in a worktree with that .env (project adm-ports-check). ./gradlew integrationTest ran against both at the same time, and all 12 tests passed in each. Each app's log showed only its own deploy job.
  • Starting both stacks together took about 4 minutes, with load around 13 on 6 CPUs. Each stack uses about 4 GB of memory (Oracle 2.4 GB), so this 11 GB VM fits two.

That simultaneous start exposed a bug in #24's tests: they didn't wait for Keycloak's setup. That's fixed on #24 (9d46791).

Not checked: the devcontainer, and Compose versions older than the VM's.

🤖 Generated with Claude Code

Two copies of the stack, or adm and another project, could not run at
once on one machine: every host port was fixed, and so was every
container name.

Each published port now comes from an ADM_*_PORT variable, which
docker compose reads from the environment or from .env, defaulting to
the port it used before. Keycloak's frontend URL and redirect URIs, and
the app's KEYCLOAK_FRONTEND_SERVER_URL and FRONTEND_SERVER_URL, follow
ADM_KEYCLOAK_PORT and ADM_HTTPS_PORT, so logins and token issuers match
the ports in use.

The services no longer set container_name, so Compose names containers,
network, and images after the project directory (adm-oracle-1 and so
on), and a copy in a git worktree gets its own.

The integrationTest task passes the ADM_* variables in .env to the
tests, which build their default URLs from ADM_HTTPS_PORT and
ADM_KEYCLOAK_PORT. The README lists the variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@slominskir
slominskir merged commit 48a870c into integration-tests Oct 1, 2026
@slominskir
slominskir deleted the configurable-ports branch October 1, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant