version: '3.8' # ================================================================================================ # STAGING ENVIRONMENT - Wave D Deployment Testing # ================================================================================================ # Purpose: Isolated staging environment for Wave D rollback testing and validation # Database: foxhunt_staging (separate from production/dev) # Redis: Port 6380 (separate from dev 6379) # Services: Isolated ports to run alongside development environment # All 5 microservices: API Gateway, Trading Service, Backtesting Service, ML Training Service, Trading Agent Service # ================================================================================================ services: # ============================================================================================== # INFRASTRUCTURE SERVICES # ============================================================================================== # PostgreSQL Staging - Isolated TimescaleDB instance postgres_staging: image: timescale/timescaledb:latest-pg16 container_name: foxhunt-postgres-staging environment: POSTGRES_DB: foxhunt_staging POSTGRES_USER: foxhunt POSTGRES_PASSWORD: foxhunt_staging_password ports: - "5433:5432" # Offset port to avoid conflict with dev (5432) volumes: - postgres_staging_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U foxhunt"] interval: 10s timeout: 5s retries: 5 networks: - foxhunt-staging restart: unless-stopped # Redis Staging - Isolated cache instance redis_staging: image: redis:7-alpine container_name: foxhunt-redis-staging command: > redis-server --maxmemory 2gb --maxmemory-policy allkeys-lru ports: - "6380:6379" # Offset port to avoid conflict with dev (6379) volumes: - redis_staging_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 networks: - foxhunt-staging restart: unless-stopped # HashiCorp Vault Staging - Secrets management vault_staging: image: hashicorp/vault:1.15 container_name: foxhunt-vault-staging environment: VAULT_ADDR: http://0.0.0.0:8200 VAULT_DEV_ROOT_TOKEN_ID: foxhunt-staging-root ports: - "8201:8200" # Offset port to avoid conflict with dev (8200) volumes: - vault_staging_data:/vault/data cap_add: - IPC_LOCK command: vault server -dev -dev-listen-address=0.0.0.0:8200 healthcheck: test: ["CMD", "vault", "status"] interval: 30s timeout: 10s retries: 5 networks: - foxhunt-staging restart: unless-stopped # MinIO Staging - S3-compatible object storage minio_staging: image: minio/minio:latest container_name: foxhunt-minio-staging ports: - "9002:9000" # API endpoint (dev is 9000) - "9003:9001" # Console UI (dev is 9001) environment: MINIO_ROOT_USER: foxhunt MINIO_ROOT_PASSWORD: foxhunt_staging_password MINIO_REGION_NAME: us-east-1 command: server /data --console-address ":9001" volumes: - minio_staging_data:/data healthcheck: test: ["CMD", "mc", "ready", "local"] interval: 10s timeout: 5s retries: 5 networks: - foxhunt-staging restart: unless-stopped # ============================================================================================== # APPLICATION SERVICES (All 5 Microservices) # ============================================================================================== # Trading Service Staging (port 50062) trading_service_staging: build: context: . dockerfile: services/trading_service/Dockerfile container_name: foxhunt-trading-service-staging env_file: - .env.staging depends_on: postgres_staging: condition: service_healthy redis_staging: condition: service_healthy vault_staging: condition: service_healthy environment: - DATABASE_URL=postgresql://foxhunt:foxhunt_staging_password@postgres_staging:5432/foxhunt_staging - REDIS_URL=redis://redis_staging:6379 - VAULT_ADDR=http://vault_staging:8200 - VAULT_TOKEN=foxhunt-staging-root - JWT_SECRET=${JWT_SECRET:-staging_secret_key_change_in_production} - JWT_ISSUER=foxhunt-api-gateway-staging - JWT_AUDIENCE=foxhunt-services-staging - TLS_ENABLED=false - RUST_LOG=info - RUST_BACKTRACE=1 - ENVIRONMENT=staging ports: - "50062:50051" # gRPC (dev is 50052) - "9102:9092" # Metrics (dev is 9092) volumes: - ./certs:/tmp/foxhunt/certs:ro networks: - foxhunt-staging restart: unless-stopped healthcheck: test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:50051"] interval: 10s timeout: 5s start_period: 30s retries: 3 # Backtesting Service Staging (port 50063) backtesting_service_staging: build: context: . dockerfile: services/backtesting_service/Dockerfile container_name: foxhunt-backtesting-service-staging env_file: - .env.staging depends_on: postgres_staging: condition: service_healthy redis_staging: condition: service_healthy vault_staging: condition: service_healthy environment: - DATABASE_URL=postgresql://foxhunt:foxhunt_staging_password@postgres_staging:5432/foxhunt_staging - REDIS_URL=redis://redis_staging:6379 - VAULT_ADDR=http://vault_staging:8200 - VAULT_TOKEN=foxhunt-staging-root - JWT_SECRET=${JWT_SECRET:-staging_secret_key_change_in_production} - JWT_ISSUER=foxhunt-api-gateway-staging - JWT_AUDIENCE=foxhunt-services-staging - BENZINGA_API_KEY=${BENZINGA_API_KEY:-demo_key_please_replace} # DBN Data Configuration - Use test data for staging - USE_DBN_DATA=true - DBN_SYMBOL_MAPPINGS=ES.FUT:/workspace/test_data/real/databento/ml_training_small/ES.FUT_ohlcv-1m_2024-01-02.dbn,NQ.FUT:/workspace/test_data/real/databento/NQ.FUT_ohlcv-1m_2024-01-02.dbn - DBN_SYMBOL_MAP=BTC/USD:ES.FUT,ETH/USD:ES.FUT - TLS_ENABLED=false - RUST_LOG=info - RUST_BACKTRACE=1 - ENVIRONMENT=staging ports: - "50063:50053" # gRPC (dev is 50053) - "9103:9093" # Metrics (dev is 9093) - "8093:8082" # Health (dev is 8083) volumes: - ./certs:/tmp/foxhunt/certs:ro - ./test_data:/workspace/test_data:ro networks: - foxhunt-staging restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8082/health"] interval: 10s timeout: 5s start_period: 30s retries: 3 # ML Training Service Staging (port 50064) ml_training_service_staging: build: context: . dockerfile: services/ml_training_service/Dockerfile container_name: foxhunt-ml-training-service-staging runtime: nvidia env_file: - .env.staging depends_on: postgres_staging: condition: service_healthy redis_staging: condition: service_healthy vault_staging: condition: service_healthy minio_staging: condition: service_healthy environment: - DATABASE_URL=postgresql://foxhunt:foxhunt_staging_password@postgres_staging:5432/foxhunt_staging - REDIS_URL=redis://redis_staging:6379 - VAULT_ADDR=http://vault_staging:8200 - VAULT_TOKEN=foxhunt-staging-root - JWT_SECRET=${JWT_SECRET:-staging_secret_key_change_in_production} - JWT_ISSUER=foxhunt-api-gateway-staging - JWT_AUDIENCE=foxhunt-services-staging # GPU Configuration - NVIDIA_VISIBLE_DEVICES=all - NVIDIA_DRIVER_CAPABILITIES=compute,utility - CUDA_VISIBLE_DEVICES=0 # MinIO Configuration - S3_ENDPOINT=http://minio_staging:9000 - S3_ACCESS_KEY=foxhunt - S3_SECRET_KEY=foxhunt_staging_password - S3_BUCKET=ml-models-staging - S3_REGION=us-east-1 # Hyperparameter Tuning - OPTUNA_STORAGE=postgresql://foxhunt:foxhunt_staging_password@postgres_staging:5432/foxhunt_staging - OPTUNA_STUDY_NAME=foxhunt-hpt-staging - OPTUNA_N_TRIALS=100 - TLS_ENABLED=false - RUST_LOG=info - RUST_BACKTRACE=1 - ENVIRONMENT=staging ports: - "50064:50053" # gRPC (dev is 50054) - "9104:9094" # Metrics (dev is 9094) - "8097:8080" # Health (dev is 8095) volumes: - ./certs:/tmp/foxhunt/certs:ro - ./models:/tmp/foxhunt/models - ./checkpoints:/tmp/foxhunt/checkpoints - ./test_data/real/databento/ml_training:/data/training:ro - ./tuning_config.yaml:/app/tuning_config.yaml:ro - ./optuna_studies:/app/optuna_studies deploy: resources: reservations: devices: - driver: nvidia count: 1 capabilities: [gpu] networks: - foxhunt-staging restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 10s timeout: 5s start_period: 30s retries: 3 # Trading Agent Service Staging (port 50065) trading_agent_service_staging: build: context: . dockerfile: services/trading_agent_service/Dockerfile container_name: foxhunt-trading-agent-service-staging env_file: - .env.staging depends_on: postgres_staging: condition: service_healthy redis_staging: condition: service_healthy vault_staging: condition: service_healthy environment: - DATABASE_URL=postgresql://foxhunt:foxhunt_staging_password@postgres_staging:5432/foxhunt_staging - REDIS_URL=redis://redis_staging:6379 - VAULT_ADDR=http://vault_staging:8200 - VAULT_TOKEN=foxhunt-staging-root - JWT_SECRET=${JWT_SECRET:-staging_secret_key_change_in_production} - TLS_ENABLED=false - RUST_LOG=info - RUST_BACKTRACE=1 - ENVIRONMENT=staging ports: - "50065:50055" # gRPC (dev is 50055) - "8085:8083" # Health (dev is 8083) - "9105:9095" # Metrics (dev is 9095) volumes: - ./certs:/tmp/foxhunt/certs:ro networks: - foxhunt-staging restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8083/health"] interval: 10s timeout: 5s start_period: 30s retries: 3 # API Gateway Staging (port 50061) api_gateway_staging: build: context: . dockerfile: services/api_gateway/Dockerfile container_name: foxhunt-api-gateway-staging env_file: - .env.staging depends_on: postgres_staging: condition: service_healthy redis_staging: condition: service_healthy vault_staging: condition: service_healthy trading_service_staging: condition: service_healthy backtesting_service_staging: condition: service_healthy ml_training_service_staging: condition: service_healthy environment: - GATEWAY_BIND_ADDR=0.0.0.0:50050 - DATABASE_URL=postgresql://foxhunt:foxhunt_staging_password@postgres_staging:5432/foxhunt_staging - REDIS_URL=redis://redis_staging:6379 - VAULT_ADDR=http://vault_staging:8200 - VAULT_TOKEN=foxhunt-staging-root - TRADING_SERVICE_URL=http://trading_service_staging:50051 - BACKTESTING_SERVICE_URL=http://backtesting_service_staging:50053 - ML_TRAINING_SERVICE_URL=http://ml_training_service_staging:50053 - JWT_SECRET=${JWT_SECRET:-staging_secret_key_change_in_production} - JWT_ISSUER=foxhunt-api-gateway-staging - JWT_AUDIENCE=foxhunt-services-staging - TLS_ENABLED=false - RATE_LIMIT_RPS=100 - ENABLE_AUDIT_LOGGING=true - RUST_LOG=info - RUST_BACKTRACE=1 - ENVIRONMENT=staging ports: - "50061:50050" # gRPC (dev is 50051) - "9101:9091" # Metrics (dev is 9091) volumes: - ./certs:/tmp/foxhunt/certs:ro networks: - foxhunt-staging restart: unless-stopped healthcheck: test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:50050"] interval: 10s timeout: 5s start_period: 30s retries: 3 volumes: postgres_staging_data: name: foxhunt-postgres-staging-data redis_staging_data: name: foxhunt-redis-staging-data vault_staging_data: name: foxhunt-vault-staging-data minio_staging_data: name: foxhunt-minio-staging-data networks: foxhunt-staging: driver: bridge name: foxhunt-staging-network