# TSU-WAVE Docker Compose Configuration version: '3.8' services: # ===== PostgreSQL with TimescaleDB ===== postgres: image: timescale/timescaledb:latest-pg14 container_name: tsuwave-postgres restart: unless-stopped environment: POSTGRES_DB: tsuwave POSTGRES_USER: tsuwave_user POSTGRES_PASSWORD: ${DB_PASSWORD:-tsuwave_secure_password} volumes: - postgres_data:/var/lib/postgresql/data - ./database/init.sql:/docker-entrypoint-initdb.d/init.sql ports: - "5432:5432" networks: - tsuwave-network healthcheck: test: ["CMD-SHELL", "pg_isready -U tsuwave_user -d tsuwave"] interval: 10s timeout: 5s retries: 5 # ===== Redis Cache ===== redis: image: redis:7-alpine container_name: tsuwave-redis restart: unless-stopped command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-redis_secure_password} volumes: - redis_data:/data ports: - "6379:6379" networks: - tsuwave-network healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 # ===== TSU-WAVE Core (NSWE Solver + Parameter Computation) ===== core: build: context: . dockerfile: Dockerfile container_name: tsuwave-core restart: unless-stopped depends_on: postgres: condition: service_healthy redis: condition: service_healthy environment: TSUWAVE_ENV: production TSUWAVE_DB_HOST: postgres TSUWAVE_DB_PORT: 5432 TSUWAVE_DB_NAME: tsuwave TSUWAVE_DB_USER: tsuwave_user TSUWAVE_DB_PASSWORD: ${DB_PASSWORD:-tsuwave_secure_password} TSUWAVE_REDIS_HOST: redis TSUWAVE_REDIS_PORT: 6379 TSUWAVE_REDIS_PASSWORD: ${REDIS_PASSWORD:-redis_secure_password} TSUWAVE_LOG_LEVEL: INFO volumes: - ./config:/app/config:ro - ./data:/app/data - ./logs:/app/logs networks: - tsuwave-network command: python src/main.py healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 # ===== TSU-WAVE API Server ===== api: build: context: . dockerfile: Dockerfile container_name: tsuwave-api restart: unless-stopped depends_on: core: condition: service_healthy environment: TSUWAVE_ENV: production TSUWAVE_DB_HOST: postgres TSUWAVE_DB_PORT: 5432 TSUWAVE_DB_NAME: tsuwave TSUWAVE_DB_USER: tsuwave_user TSUWAVE_DB_PASSWORD: ${DB_PASSWORD:-tsuwave_secure_password} TSUWAVE_REDIS_HOST: redis TSUWAVE_REDIS_PORT: 6379 TSUWAVE_REDIS_PASSWORD: ${REDIS_PASSWORD:-redis_secure_password} TSUWAVE_API_HOST: 0.0.0.0 TSUWAVE_API_PORT: 8000 TSUWAVE_JWT_SECRET: ${JWT_SECRET:-your_jwt_secret_key_change_me} volumes: - ./config:/app/config:ro ports: - "8000:8000" networks: - tsuwave-network command: uvicorn tsuwave.api.main:app --host 0.0.0.0 --port 8000 --workers 4 healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8000/health"] interval: 30s timeout: 10s retries: 3 # ===== TSU-WAVE Dashboard (Streamlit) ===== dashboard: build: context: . dockerfile: Dockerfile container_name: tsuwave-dashboard restart: unless-stopped depends_on: api: condition: service_healthy environment: TSUWAVE_ENV: production TSUWAVE_API_URL: http://api:8000 TSUWAVE_DASHBOARD_PORT: 8080 ports: - "8080:8080" networks: - tsuwave-network command: streamlit run src/tsuwave/dashboard/app.py --server.port=8080 --server.address=0.0.0.0 --server.enableCORS=false # ===== Nginx Reverse Proxy ===== nginx: image: nginx:alpine container_name: tsuwave-nginx restart: unless-stopped depends_on: - api - dashboard volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro - ./nginx/sites:/etc/nginx/sites-enabled:ro ports: - "80:80" - "443:443" networks: - tsuwave-network # ===== Data Initialization (Run once) ===== init: build: context: . dockerfile: Dockerfile container_name: tsuwave-init depends_on: postgres: condition: service_healthy redis: condition: service_healthy environment: TSUWAVE_ENV: production TSUWAVE_DB_HOST: postgres TSUWAVE_DB_PORT: 5432 TSUWAVE_DB_NAME: tsuwave TSUWAVE_DB_USER: tsuwave_user TSUWAVE_DB_PASSWORD: ${DB_PASSWORD:-tsuwave_secure_password} TSUWAVE_REDIS_HOST: redis TSUWAVE_REDIS_PORT: 6379 TSUWAVE_REDIS_PASSWORD: ${REDIS_PASSWORD:-redis_secure_password} volumes: - ./config:/app/config:ro - ./data:/app/data networks: - tsuwave-network command: > sh -c " python scripts/setup_database.py && python scripts/load_becf_maps.py && python scripts/load_validation_data.py " profiles: - init # ===== Volumes ===== volumes: postgres_data: name: tsuwave-postgres-data redis_data: name: tsuwave-redis-data # ===== Networks ===== networks: tsuwave-network: name: tsuwave-network driver: bridge