fix(Dockerfile): healthcheck hits catch-all route instead of API — use /api/ping and verify response body#1582
Open
Yunaido wants to merge 2 commits intoevroon:masterfrom
Conversation
…ist file permissions
…e /api/ping and verify response body
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 combined
Dockerfilehealthcheck uses/ping:This is broken in two ways when
SERVE_FRONTEND=true:1. Wrong path — always returns 200 regardless of API health
When
SERVE_FRONTEND=true, FastAPI installs a catch-all route:Any path that doesn't match an API route — including
/ping— is caught hereand returns
index.htmlwith HTTP 200. The healthcheck passes even if theFastAPI app, database connection, or API router are completely broken.
The correct path is
/api/ping, which is resolved by the API router (mountedunder
API_PREFIX=/api) before the catch-all, and only returns 200 when thebackend is genuinely alive.
2. No response body verification
Even with the correct path,
wget -O /dev/nulldiscards the response body.A 200 from the catch-all would still pass. Checking for
"ping"in theresponse body proves the actual FastAPI endpoint responded — not just that
something returned 200.
3. Interval too aggressive
interval=3swithretries=10means Docker marks a container unhealthy after30 seconds of any hiccup, and hammers the endpoint every 3 seconds in normal
operation. 30s/5s/5 retries is standard production behaviour.
Fix
/api/ping— hits the real FastAPI endpoint, not the catch-allgrep -q '"ping"'ensures the API actually responded