Skip to content

Healthcheck Summary

Overview

All services across all environments (qualification, production, development) now have healthchecks configured. This ensures proper container health monitoring and enables Docker Compose to manage service dependencies correctly.

Healthcheck Configuration

Standard Healthcheck Pattern

Most services use the following standard healthcheck configuration:

healthcheck:
  test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1:3000/api/health || exit 1"]
  interval: 30s
  timeout: 10s
  retries: 5
  start_period: 30s

Service-Specific Healthchecks

Frontend Services

  • public-fo (Nginx): Checks port 80
    test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1:80 || exit 1"]
    start_period: 30s
    

CMS Services

  • strapi-cms: Checks port 1337
    test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1:1337 || exit 1"]
    start_period: 60s  # Strapi takes longer to start
    

Identity Provider

  • keycloak: Checks /health/ready endpoint on port 8080
    test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1:8080/health/ready || exit 1"]
    start_period: 60s  # Keycloak takes longer to initialize
    

NestJS Services (Express-style endpoints)

These services expose /api/health endpoints: - notification-service - analytics-service - review-service - file-service

test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1:3000/api/health || exit 1"]

Express Services

These services expose /health endpoints: - api-gateway - user-management - booking-service - experience-service - payment-service - auth-service

test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://127.0.0.1:3000/health || exit 1"]

Note: Some services use nc -z (netcat) instead of wget for port checks: - api-gateway-qual - auth-service-qual - payment-service-qual - file-service-qual

test: ["CMD-SHELL", "nc -z 127.0.0.1 3000 || exit 1"]

Environment Coverage

Qualification Environment (qualification.yml)

All 14 services have healthchecks: - ✅ public-fo-qual - ✅ strapi-cms-qual - ✅ api-gateway-qual - ✅ keycloak-qual - ✅ auth-service-qual - ✅ user-management-qual - ✅ booking-service-qual - ✅ experience-service-qual - ✅ payment-service-qual - ✅ notification-service-qual - ✅ analytics-service-qual - ✅ file-service-qual - ✅ review-service-qual

Production Environment (production.yml)

All 14 services have healthchecks: - ✅ public-fo-prod - ✅ strapi-cms-prod - ✅ api-gateway-prod - ✅ keycloak-prod - ✅ user-management-prod - ✅ booking-service-prod - ✅ experience-service-prod - ✅ payment-service-prod - ✅ notification-service-prod - ✅ analytics-service-prod - ✅ file-service-prod - ✅ review-service-prod - ✅ auth-service-prod

Development Environment (development.yml)

All services already had healthchecks configured.

Shared Infrastructure (shared.yml)

All infrastructure services have healthchecks: - ✅ traefik - ✅ postgres - ✅ redis - ✅ rabbitmq - ✅ adminer - ✅ minio

Healthcheck Parameters

  • interval: 30s (10s for Traefik)
  • timeout: 10s (5s for Traefik)
  • retries: 5 (3 for Traefik)
  • start_period:
  • 30s for most services
  • 60s for Strapi and Keycloak (longer initialization)
  • 10s for Traefik

Benefits

  1. Service Dependencies: Docker Compose can use depends_on with condition: service_healthy to ensure services start in the correct order.

  2. Container Status: docker ps shows health status (healthy, unhealthy, starting).

  3. Automatic Restart: Unhealthy containers can be automatically restarted based on restart policies.

  4. Monitoring: Healthcheck status can be monitored by external tools (Prometheus, Grafana).

  5. Debugging: Healthcheck failures help identify service startup issues quickly.

Verification

To verify all services have healthchecks:

# Count healthchecks in qualification.yml
grep -c "healthcheck:" infrastructure/compose/qualification.yml

# Count healthchecks in production.yml
grep -c "healthcheck:" infrastructure/compose/production.yml

# View health status of running containers
docker ps --format "table {{.Names}}\t{{.Status}}"