Skip to content

Unify java-auth on port 8081 (internal == external)#169

Merged
kenahrens merged 1 commit into
masterfrom
chore/java-auth-unify-port-8081
Jun 12, 2026
Merged

Unify java-auth on port 8081 (internal == external)#169
kenahrens merged 1 commit into
masterfrom
chore/java-auth-unify-port-8081

Conversation

@kenahrens

Copy link
Copy Markdown
Member

Problem

The Compose host port 8081 mapped to the container's 8080, so the app config, Dockerfile, k8s manifests, and Java client all spoke 8080 while the host mapping, README, and demo script spoke 8081. A port mapping that translates (8081:8080) is confusing and easy to trip over — running ./scripts/test.sh against the wrong port fails silently.

Solution

Make 8081 the app's actual port everywhere, so internal == external with no translation:

  • server/src/main/resources/application.ymlserver.port: 8081
  • server/DockerfileEXPOSE 8081 + healthcheck on 8081
  • docker-compose.yml8081:8081, SERVER_URL: http://auth-service:8081
  • client/.../AuthClient.java — default SERVER_URLlocalhost:8081
  • k8s (base + statefulset): containerPort, targetPort, liveness/readiness probes, SERVER_PORT configmaps → 8081

The two k8s Service port: 80 entries stay as-is — that's normal in-cluster service routing to the pod's 8081, not a host/container mismatch. README.md and scripts/test.sh already used 8081.

Verified locally: docker compose up -d --build comes up clean, the container binds 0.0.0.0:8081->8081, and health + login + protected /api/auth/user calls all pass.

Note: MySQL is still 3307:3306 (host 3307 avoids a local collision; container keeps the conventional 3306). Left as-is since 3306 is the expected MySQL port inside the container — easy to fold in if we want full symmetry.

The Compose host port (8081) translated to the container's 8080, so the
app, Dockerfile, k8s manifests, and client all spoke 8080 while the host
and the demo script spoke 8081. That host:container split is confusing
and error-prone.

Move the app's actual port to 8081 everywhere: application.yml
server.port, Dockerfile EXPOSE + healthcheck, Compose mapping (8081:8081)
and SERVER_URL, the client's default SERVER_URL, and all k8s
containerPort / targetPort / probe / SERVER_PORT references. The k8s
Service port stays 80 (normal in-cluster service routing to the pod's
8081). README and scripts/test.sh already use 8081.

Verified: docker compose up rebuilds clean, app binds 8081
(0.0.0.0:8081->8081), health + login + protected calls all pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kenahrens kenahrens merged commit 34880dd into master Jun 12, 2026
29 checks passed
@kenahrens kenahrens deleted the chore/java-auth-unify-port-8081 branch June 12, 2026 00:00
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