Files
SQL/docker-compose.yml
T
Alphaeus Mote 75fa7e0159 Fix container startup timing and pgAdmin health check issues
DEPLOY SCRIPT IMPROVEMENTS:

- Start PostgreSQL first with --no-deps flag

- Wait for PostgreSQL to be healthy (increased to 120 seconds)

- Start pgAdmin separately after PostgreSQL is ready

- Added note that pgAdmin takes 30-60 seconds to initialize

- pgAdmin startup no longer blocks database operations

DOCKER COMPOSE FIX:

- Removed health check condition from pgAdmin depends_on

- Changed from 'condition: service_healthy' to simple dependency

- pgAdmin can start independently without waiting for PostgreSQL health

- Prevents 'Container is unhealthy' errors during startup

TROUBLESHOOTING SECTION:

- Added troubleshooting tips to deploy.sh output

- Command to check pgAdmin status: docker logs business_analytics_ui

- Instructions to wait for pgAdmin initialization

- Look for 'Listening at: http://[::]:80' in logs

BENEFITS:

- No more 'Container is unhealthy' errors

- Database operations can proceed while pgAdmin initializes

- Clear user expectations about pgAdmin startup time

- Better error handling and troubleshooting guidance
2025-10-24 12:22:35 -04:00

61 lines
1.8 KiB
YAML

# ============================================================================
# Business Analytics Database - Docker Compose Configuration
# ============================================================================
# IMPORTANT: Before running docker-compose up, ensure proper permissions:
# Run: ./scripts/fix-permissions.sh
# Or: sudo chown -R $USER:$USER . && chmod -R 755 data/ schema/ scripts/
# ============================================================================
services:
postgres:
image: postgres:16-alpine
container_name: business_analytics_db
environment:
POSTGRES_DB: business_analytics
POSTGRES_USER: data_analyst
POSTGRES_PASSWORD: SecurePass123!
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./schema:/docker-entrypoint-initdb.d # Bind mount - requires proper permissions
- ./data:/data # Bind mount - requires proper permissions
networks:
- analytics_network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U data_analyst -d business_analytics"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
pgadmin:
image: dpage/pgadmin4:latest
container_name: business_analytics_ui
environment:
PGADMIN_DEFAULT_EMAIL: admin@example.com
PGADMIN_DEFAULT_PASSWORD: SecurePass123!
PGADMIN_CONFIG_SERVER_MODE: 'False'
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: 'False'
ports:
- "3000:80"
networks:
- analytics_network
depends_on:
- postgres
restart: unless-stopped
volumes:
- pgadmin_data:/var/lib/pgadmin
networks:
analytics_network:
driver: bridge
volumes:
postgres_data:
driver: local
pgadmin_data:
driver: local