ca-grow-ops-manager/docs/SPRINT-1-HEALTHCHECK.md
fullsizemalt d2c3e67e40 fix: Change health check from curl to wget for alpine compatibility
- Backend container uses node:20-alpine which doesn't include curl
- wget is available by default in alpine
- Health check endpoint is working, just the command was wrong
- Also added Sprint 1 documentation and credentials file
2025-12-09 13:39:43 -08:00

111 lines
2.2 KiB
Markdown

# Sprint 1: Fix Backend Health Check
**Date**: 2025-12-09
**Status**: In Progress
**Duration**: 30 minutes
**Priority**: 🔴 Critical
---
## 🎯 Objective
Fix the unhealthy backend container by resolving the Docker health check issue.
---
## 🔍 Problem Diagnosis
### Current State
```
ca-grow-ops-manager-backend-1 Up 41 minutes (unhealthy)
```
### Root Cause
The health check in `docker-compose.yml` uses `curl`:
```yaml
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:3000/api/healthz" ]
```
However, the backend container (node:20-alpine) **does not have curl installed**.
### Evidence
- Backend logs show server is running: `Server listening at http://0.0.0.0:3000`
- Backend is successfully serving requests (login, rooms endpoints working)
- Health check endpoint exists at `/api/healthz`
---
## ✅ Solution
### Option 1: Use wget (already available in alpine)
Change health check to use `wget` instead of `curl`.
### Option 2: Install curl in Dockerfile
Add `curl` to the alpine packages.
**Chosen**: Option 1 (wget) - simpler, no rebuild needed for testing.
---
## 📋 Implementation Steps
1. ✅ Diagnose issue (check logs, verify endpoint exists)
2. ⏳ Update `docker-compose.yml` health check to use `wget`
3. ⏳ Commit and push changes
4. ⏳ Deploy to nexus-vector
5. ⏳ Verify health check passes
---
## 🧪 Testing
### Manual Test
```bash
# SSH to nexus-vector
ssh admin@nexus-vector
# Test wget works in container
docker exec ca-grow-ops-manager-backend-1 wget -q -O- http://localhost:3000/api/healthz
# Expected output:
# {"status":"ok","timestamp":"2025-12-09T..."}
```
### Verify Health
```bash
docker compose ps
# All services should show (healthy)
```
---
## 📊 Success Criteria
- [ ] Backend container shows `(healthy)` status
- [ ] Health check endpoint returns 200 OK
- [ ] No errors in backend logs
- [ ] Application remains accessible at <https://777wolfpack.runfoo.run>
---
## 🔗 Related Files
- `docker-compose.yml` (line 53)
- `backend/src/server.ts` (line 28-30)
---
## 📝 Notes
- Backend is actually working fine, just the health check command is wrong
- This is a non-breaking fix (won't affect running services)
- After fix, Docker will correctly report container health