Make server port configurable, and let compose host ports be overridden - #120
Open
justinleveck wants to merge 2 commits into
Open
Make server port configurable, and let compose host ports be overridden#120justinleveck wants to merge 2 commits into
justinleveck wants to merge 2 commits into
Conversation
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
force-pushed
the
fix/configurable-server-port
branch
from
August 7, 2026 02:53
514deae to
1053c7e
Compare
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
server/src/index.tsreads the port fromPORT(default3001, 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 adocker-compose.override.ymlbecause Compose concatenates (not replaces) list-type keys likeportsacross-ffiles, so an override file wouldn't actually fix a collision on the base port.3000for consistency between the Dockerfile, nginx'sproxy_pass, and the compose env - the host-facing3001/5173mapping is unchanged from today, so no README doc drift..gitignorepicks updocker-compose.override.ymlas another local-only path (.env/.env.*was already ignored).Test plan
docker compose config --quietvalidates with defaultsdocker compose configconfirmsSERVER_PORT=4001 CLIENT_PORT=8080resolves to the expected published ports, and defaults resolve to3001/5173unchangedtsc -bclean onclient/