fix: Docker HEALTHCHECK respects $PORT env var (#291)#292
Merged
Conversation
The HEALTHCHECK CMD hardcoded port 8000, so containers with a
custom PORT env var were reported as unhealthy. Use ${PORT:-8000}
so the health probe respects the configured port.
4 tasks
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.
Problem
The HEALTHCHECK in the Dockerfile hardcodes port 8000, but the app port is configurable via the
PORTenvironment variable. When a container is started with-e PORT=6100, the health check still probes port 8000 → connection refused → Docker marks the containerunhealthy.Solution
Changed:
CMD curl -f http://localhost:8000/health || exit 1to:
Shell interpolates
$PORTat health-check runtime, falling back to 8000 when unset. Zero code changes needed.Acceptance criteria
$PORTenv var with fallback to8000PORTset) → probes port 8000 (unchanged)-e PORT=6100) → probes port 6100Closes #291