diff --git a/docker-compose.yml b/docker-compose.yml index ed9f136..ebde692 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -50,7 +50,7 @@ services: networks: - internal healthcheck: - test: [ "CMD", "wget", "-q", "-O-", "http://localhost:3000/api/healthz" ] + test: [ "CMD", "wget", "-q", "-O-", "http://127.0.0.1:3000/api/healthz" ] interval: 30s timeout: 10s retries: 3 diff --git a/docs/SPRINT-1-HEALTHCHECK.md b/docs/SPRINT-1-HEALTHCHECK.md index b6e9679..1dea42e 100644 --- a/docs/SPRINT-1-HEALTHCHECK.md +++ b/docs/SPRINT-1-HEALTHCHECK.md @@ -1,7 +1,7 @@ # Sprint 1: Fix Backend Health Check **Date**: 2025-12-09 -**Status**: In Progress +**Status**: ✅ Complete **Duration**: 30 minutes **Priority**: 🔴 Critical @@ -42,15 +42,21 @@ However, the backend container (node:20-alpine) **does not have curl installed** ## ✅ Solution -### Option 1: Use wget (already available in alpine) +### Final Fix -Change health check to use `wget` instead of `curl`. +Changed health check to use: -### Option 2: Install curl in Dockerfile +1. **wget** instead of curl (alpine has wget by default) +2. **127.0.0.1** instead of localhost (avoids DNS resolution issues in Docker networking) -Add `curl` to the alpine packages. +```yaml +healthcheck: + test: [ "CMD", "wget", "-q", "-O-", "http://127.0.0.1:3000/api/healthz" ] +``` -**Chosen**: Option 1 (wget) - simpler, no rebuild needed for testing. +### Why 127.0.0.1 instead of localhost? + +In some Docker networking configurations (especially with Tailscale or custom networks), `localhost` DNS resolution can be problematic. Using `127.0.0.1` bypasses DNS entirely and directly uses the loopback interface. --- @@ -90,10 +96,10 @@ docker compose ps ## 📊 Success Criteria -- [ ] Backend container shows `(healthy)` status -- [ ] Health check endpoint returns 200 OK -- [ ] No errors in backend logs -- [ ] Application remains accessible at +- [x] Backend container shows `(healthy)` status +- [x] Health check endpoint returns 200 OK +- [x] No errors in backend logs +- [x] Application remains accessible at > ---