diff --git a/src/go-postgres/.devcontainer/docker-compose.yml b/src/go-postgres/.devcontainer/docker-compose.yml index d8db01b1..1c99d1db 100644 --- a/src/go-postgres/.devcontainer/docker-compose.yml +++ b/src/go-postgres/.devcontainer/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - volumes: postgres-data: @@ -26,6 +24,16 @@ services: db: image: postgres:latest restart: unless-stopped + + # Health check ensures PostgreSQL is ready before dependent services start + # This is critical for depends_on with condition: service_healthy to work properly + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 10s # Check every 10 seconds + timeout: 5s # Wait up to 5 seconds for response + retries: 5 # Retry 5 times before marking as unhealthy + start_period: 30s # Give PostgreSQL 30 seconds to start before health checks begin + volumes: - postgres-data:/var/lib/postgresql env_file: