Skip to content

Commit 370d1c0

Browse files
AchoArnoldCopilot
andcommitted
fix(api): add /health endpoint for reliable Docker health checks
The health check was using wget --spider on the root path which hits the swagger catch-all route. BusyBox wget --spider may not handle the swagger response correctly, causing the API container to be marked unhealthy and preventing the seed container from starting. - Add a dedicated /health endpoint registered before middleware - Update Docker Compose health check to use /health - Update CI workflow health wait loop to use /health Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent dc3bb15 commit 370d1c0

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
echo "Waiting for API to be healthy..."
3939
for i in $(seq 1 40); do
40-
if docker compose exec api wget --spider -q http://localhost:8000/ 2>/dev/null; then
40+
if docker compose exec api wget -q -O /dev/null http://localhost:8000/health 2>/dev/null; then
4141
echo "API is healthy!"
4242
break
4343
fi

api/pkg/di/container.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ func (container *Container) App() (app *fiber.App) {
175175

176176
app = fiber.New()
177177

178+
// Health check endpoint registered before middleware for reliable Docker health checks
179+
app.Get("/health", func(c *fiber.Ctx) error {
180+
return c.SendStatus(fiber.StatusOK)
181+
})
182+
178183
if os.Getenv("USE_HTTP_LOGGER") == "true" {
179184
app.Use(fiberLogger.New())
180185
}

tests/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ services:
5757
environment:
5858
FIREBASE_CREDENTIALS: "${FIREBASE_CREDENTIALS}"
5959
healthcheck:
60-
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8000/"]
60+
test:
61+
["CMD", "wget", "-q", "-O", "/dev/null", "http://localhost:8000/health"]
6162
interval: 5s
6263
timeout: 10s
6364
retries: 20

0 commit comments

Comments
 (0)