version: '3.8' services: # ============================================================================ # Broker Gateway Service - Main Application # ============================================================================ broker_gateway: build: context: ../.. dockerfile: services/broker_gateway_service/Dockerfile.production args: GIT_COMMIT: ${GIT_COMMIT:-dev} BUILD_DATE: ${BUILD_DATE:-2025-11-09} VERSION: ${VERSION:-0.1.0} image: jgrusewski/foxhunt-broker-gateway:${VERSION:-latest} container_name: foxhunt-broker-gateway restart: unless-stopped depends_on: postgres: condition: service_healthy redis: condition: service_healthy ports: - "50056:50056" # gRPC port - "8086:8086" # Health check HTTP endpoint - "9096:9096" # Prometheus metrics endpoint environment: # Service configuration GRPC_PORT: 50056 HEALTH_PORT: 8086 METRICS_PORT: 9096 # Database configuration DATABASE_URL: postgresql://foxhunt:foxhunt_dev_password@postgres:5432/foxhunt DATABASE_POOL_SIZE: 20 DATABASE_TIMEOUT_SECONDS: 30 # Redis configuration REDIS_URL: redis://redis:6379 REDIS_POOL_SIZE: 10 REDIS_TIMEOUT_SECONDS: 5 # Broker configuration (CQG via AMP Futures) CQG_HOST: ${CQG_HOST:-fix.amp.cqg.com} CQG_PORT: ${CQG_PORT:-6100} CQG_SENDER_COMP_ID: ${CQG_SENDER_COMP_ID:-FOXHUNT_DEMO} CQG_TARGET_COMP_ID: ${CQG_TARGET_COMP_ID:-AMPFUTURES} CQG_HEARTBEAT_INTERVAL: ${CQG_HEARTBEAT_INTERVAL:-30} # FIX protocol configuration FIX_VERSION: ${FIX_VERSION:-FIX.4.4} FIX_LOG_DIR: /app/logs/fix FIX_SESSION_TIMEOUT: ${FIX_SESSION_TIMEOUT:-60} # Observability RUST_LOG: ${RUST_LOG:-info,broker_gateway_service=debug,sqlx=warn} RUST_BACKTRACE: ${RUST_BACKTRACE:-1} # Feature flags ENABLE_FIX_PROTOCOL: ${ENABLE_FIX_PROTOCOL:-false} MVP_MODE: ${MVP_MODE:-true} volumes: # FIX logs (persistent) - broker_gateway_logs:/app/logs # FIX session store (persistent for message recovery) - broker_gateway_data:/app/data networks: - foxhunt-network healthcheck: test: ["CMD", "/usr/local/bin/grpc_health_probe", "-addr=localhost:50056"] interval: 10s timeout: 5s retries: 3 start_period: 30s deploy: resources: limits: cpus: '2' memory: 512M reservations: cpus: '0.5' memory: 256M # ============================================================================ # PostgreSQL Database # ============================================================================ postgres: image: postgres:16-alpine container_name: foxhunt-postgres restart: unless-stopped ports: - "5432:5432" environment: POSTGRES_USER: foxhunt POSTGRES_PASSWORD: foxhunt_dev_password POSTGRES_DB: foxhunt POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C" PGDATA: /var/lib/postgresql/data/pgdata volumes: - postgres_data:/var/lib/postgresql/data # Auto-apply migrations on startup (optional) - ../../migrations:/docker-entrypoint-initdb.d:ro networks: - foxhunt-network healthcheck: test: ["CMD-SHELL", "pg_isready -U foxhunt -d foxhunt"] interval: 10s timeout: 5s retries: 5 deploy: resources: limits: cpus: '2' memory: 1G reservations: cpus: '0.5' memory: 512M # ============================================================================ # Redis Cache # ============================================================================ redis: image: redis:7-alpine container_name: foxhunt-redis restart: unless-stopped ports: - "6379:6379" command: > redis-server --save 60 1000 --loglevel warning --maxmemory 256mb --maxmemory-policy allkeys-lru volumes: - redis_data:/data networks: - foxhunt-network healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 deploy: resources: limits: cpus: '1' memory: 512M reservations: cpus: '0.25' memory: 256M # ============================================================================ # Prometheus Monitoring # ============================================================================ prometheus: image: prom/prometheus:v2.48.0 container_name: foxhunt-prometheus restart: unless-stopped ports: - "9090:9090" command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--web.console.libraries=/usr/share/prometheus/console_libraries' - '--web.console.templates=/usr/share/prometheus/consoles' - '--storage.tsdb.retention.time=30d' - '--web.enable-lifecycle' volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus networks: - foxhunt-network healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9090/-/healthy"] interval: 10s timeout: 5s retries: 3 deploy: resources: limits: cpus: '1' memory: 1G reservations: cpus: '0.25' memory: 512M # ============================================================================ # Grafana Dashboards # ============================================================================ grafana: image: grafana/grafana:10.2.2 container_name: foxhunt-grafana restart: unless-stopped depends_on: - prometheus ports: - "3000:3000" environment: GF_SECURITY_ADMIN_USER: admin GF_SECURITY_ADMIN_PASSWORD: foxhunt123 GF_USERS_ALLOW_SIGN_UP: "false" GF_INSTALL_PLUGINS: grafana-clock-panel,grafana-simple-json-datasource GF_SERVER_ROOT_URL: http://localhost:3000 GF_AUTH_ANONYMOUS_ENABLED: "false" volumes: - grafana_data:/var/lib/grafana - ./grafana/provisioning:/etc/grafana/provisioning:ro - ./grafana/dashboards:/var/lib/grafana/dashboards:ro networks: - foxhunt-network healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/api/health"] interval: 10s timeout: 5s retries: 3 deploy: resources: limits: cpus: '1' memory: 512M reservations: cpus: '0.25' memory: 256M # ============================================================================ # Networks # ============================================================================ networks: foxhunt-network: driver: bridge ipam: config: - subnet: 172.28.0.0/16 # ============================================================================ # Volumes (Persistent Data) # ============================================================================ volumes: postgres_data: driver: local redis_data: driver: local broker_gateway_logs: driver: local broker_gateway_data: driver: local prometheus_data: driver: local grafana_data: driver: local