Skip to content

Make server port configurable, and let compose host ports be overridden - #120

Open
justinleveck wants to merge 2 commits into
chrkaatz:mainfrom
justinleveck:fix/configurable-server-port
Open

Make server port configurable, and let compose host ports be overridden#120
justinleveck wants to merge 2 commits into
chrkaatz:mainfrom
justinleveck:fix/configurable-server-port

Conversation

@justinleveck

Copy link
Copy Markdown

Summary

  • server/src/index.ts reads the port from PORT (default 3001, unchanged) instead of hardcoding it, so the server can run on a different port without editing source.
  • docker-compose.yml's host-side ports become ${SERVER_PORT:-3001} / ${CLIENT_PORT:-5173}, resolved via .env (see new .env.example) or inline env vars - no need to edit the tracked compose file to avoid a port collision. Went with variable substitution over a docker-compose.override.yml because Compose concatenates (not replaces) list-type keys like ports across -f files, so an override file wouldn't actually fix a collision on the base port.
  • Container-internal port also moves to 3000 for consistency between the Dockerfile, nginx's proxy_pass, and the compose env - the host-facing 3001/5173 mapping is unchanged from today, so no README doc drift.
  • README gets a new "Overriding the Ports" section, and .gitignore picks up docker-compose.override.yml as another local-only path (.env/.env.* was already ignored).

Test plan

  • docker compose config --quiet validates with defaults
  • docker compose config confirms SERVER_PORT=4001 CLIENT_PORT=8080 resolves to the expected published ports, and defaults resolve to 3001/5173 unchanged
  • tsc -b clean on client/

server/src/index.ts hardcoded port 3001, so the only way to run the
server on a different port (e.g. to avoid colliding with another local
service) was to edit source. Read PORT from the environment, defaulting
to 3001 to preserve current behavior.

Wires PORT=3000 through docker-compose.yml, keeping the host-facing
mapping fixed at 3001:3000 so `localhost:3001` still works exactly as
documented - only the container's internal port changes. Dockerfile and
nginx's proxy_pass are updated to match the new internal port.
Anyone whose 3001 or 5173 is already taken had to edit the tracked
docker-compose.yml to run the stack at all. Compose's ports list is
concatenated (not replaced) across -f files, so a docker-compose.override.yml
wouldn't actually fix a port collision - the base file's binding would
still be attempted and still fail. Variable substitution does replace
cleanly: ports now read ${SERVER_PORT:-3001} / ${CLIENT_PORT:-5173},
which docker compose resolves from a .env file (already gitignored,
see .env.example) or inline env vars, with no change to defaults.

Also gitignore docker-compose.override.yml, since it's the other
Compose-native path someone might reach for locally and shouldn't be
committed either.
@justinleveck
justinleveck force-pushed the fix/configurable-server-port branch from 514deae to 1053c7e Compare August 7, 2026 02:53
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