fix: use wget for Docker health check instead of node

Spawning a full Node process for health checks is slow on Alpine and
can exceed the 3s timeout, causing the container to be marked unhealthy.
Use wget (built into Alpine) instead, and increase start_period to 15s.
This commit is contained in:
MayaTheShy
2026-03-22 20:42:37 -04:00
parent a6bf84d6b8
commit a499446366
2 changed files with 5 additions and 5 deletions

View File

@@ -10,10 +10,10 @@ services:
- TURTLE_SERVER_URL=${TURTLE_SERVER_URL:-}
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3001/api/health',r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"]
test: ["CMD", "wget", "-qO-", "http://localhost:3001/api/health"]
interval: 10s
timeout: 3s
start_period: 5s
timeout: 5s
start_period: 15s
retries: 3
client:

View File

@@ -26,8 +26,8 @@ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
EXPOSE 3001
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3001/api/health',r=>{process.exit(r.statusCode===200?0:1)}).on('error',()=>process.exit(1))"
HEALTHCHECK --interval=10s --timeout=5s --start_period=15s --retries=3 \
CMD wget -qO- http://localhost:3001/api/health || exit 1
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["node", "server.js"]