version: '3.8' services: foxhunt-core: build: context: ../../core dockerfile: Dockerfile.production args: RUST_VERSION: 1.75.0 BUILD_MODE: release container_name: foxhunt-core-prod hostname: foxhunt-core ports: - "8080:8080" - "9090:9090" # Metrics volumes: - /opt/foxhunt/config/production.toml:/app/config/config.toml:ro - /opt/foxhunt/data:/app/data:rw - /var/log/foxhunt:/app/logs:rw - /dev/shm:/dev/shm # Shared memory for IPC environment: - RUST_LOG=info - FOXHUNT_ENV=production - FOXHUNT_CONFIG=/app/config/config.toml networks: - foxhunt-prod-net # HFT Performance Optimizations cpuset: "2-5" # Dedicated CPU cores cpu_count: 4 cpu_percent: 400 # 4 cores * 100% mem_limit: 4g memswap_limit: 4g mem_swappiness: 1 oom_kill_disable: true # Real-time capabilities cap_add: - SYS_NICE - IPC_LOCK ulimits: memlock: soft: -1 hard: -1 nofile: soft: 65536 hard: 65536 rtprio: soft: 90 hard: 90 # Network optimizations sysctls: - net.core.rmem_max=134217728 - net.core.wmem_max=134217728 - net.ipv4.tcp_rmem=4096 65536 134217728 - net.ipv4.tcp_wmem=4096 65536 134217728 - net.core.netdev_max_backlog=5000 restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/health"] interval: 10s timeout: 5s retries: 3 start_period: 30s logging: driver: "json-file" options: max-size: "100m" max-file: "10" foxhunt-tli: build: context: ../../tli dockerfile: Dockerfile.production args: RUST_VERSION: 1.75.0 BUILD_MODE: release container_name: foxhunt-tli-prod hostname: foxhunt-tli ports: - "50051:50051" # gRPC port - "8081:8081" # Health check port volumes: - /opt/foxhunt/config/production.toml:/app/config/config.toml:ro - /var/log/foxhunt:/app/logs:rw environment: - RUST_LOG=info - FOXHUNT_CORE_ENDPOINT=http://foxhunt-core:8080 - FOXHUNT_CONFIG=/app/config/config.toml - FOXHUNT_ENV=production depends_on: foxhunt-core: condition: service_healthy networks: - foxhunt-prod-net cpuset: "6-7" mem_limit: 2g restart: unless-stopped healthcheck: test: ["CMD", "grpcurl", "-plaintext", "localhost:50051", "list"] interval: 15s timeout: 10s retries: 3 start_period: 45s foxhunt-ml-training: build: context: ../../ml dockerfile: Dockerfile.production args: RUST_VERSION: 1.75.0 BUILD_MODE: release CUDA_VERSION: "12.1" container_name: foxhunt-ml-training-prod hostname: foxhunt-ml-training ports: - "8082:8082" # Health check port - "6006:6006" # TensorBoard volumes: - /opt/foxhunt/config/production.toml:/app/config/config.toml:ro - /opt/foxhunt/models:/app/models:rw - /opt/foxhunt/data:/app/data:ro - /opt/foxhunt/checkpoints:/app/checkpoints:rw - /var/log/foxhunt:/app/logs:rw - /tmp/cuda-cache:/tmp/cuda-cache:rw environment: - RUST_LOG=info - FOXHUNT_CORE_ENDPOINT=http://foxhunt-core:8080 - FOXHUNT_DATA_ENDPOINT=http://foxhunt-data:8084 - FOXHUNT_CONFIG=/app/config/config.toml - FOXHUNT_ENV=production # CUDA/GPU environment - CUDA_VISIBLE_DEVICES=0 - NVIDIA_VISIBLE_DEVICES=0 - NVIDIA_DRIVER_CAPABILITIES=compute,utility - NVIDIA_REQUIRE_CUDA=cuda>=11.8 # ML framework optimizations - OMP_NUM_THREADS=6 - MKL_NUM_THREADS=6 - PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512 - TF_GPU_MEMORY_GROWTH=true depends_on: foxhunt-core: condition: service_healthy foxhunt-data: condition: service_healthy networks: - foxhunt-prod-net # GPU-optimized resource allocation cpuset: "8-13" # Dedicated cores for ML mem_limit: 16g memswap_limit: 16g shm_size: 2g # Shared memory for ML frameworks # GPU access runtime: nvidia deploy: resources: reservations: devices: - driver: nvidia count: 1 capabilities: [gpu] restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8082/health"] interval: 30s timeout: 15s retries: 5 start_period: 120s foxhunt-risk: build: context: ../../risk dockerfile: Dockerfile.production args: RUST_VERSION: 1.75.0 BUILD_MODE: release container_name: foxhunt-risk-prod hostname: foxhunt-risk ports: - "8083:8083" volumes: - /opt/foxhunt/config/production.toml:/app/config/config.toml:ro - /opt/foxhunt/data:/app/data:ro - /var/log/foxhunt:/app/logs:rw environment: - RUST_LOG=info - FOXHUNT_CORE_ENDPOINT=http://foxhunt-core:8080 - FOXHUNT_CONFIG=/app/config/config.toml - FOXHUNT_ENV=production depends_on: foxhunt-core: condition: service_healthy networks: - foxhunt-prod-net cpuset: "14-15" mem_limit: 3g restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8083/health"] interval: 15s timeout: 5s retries: 3 start_period: 30s foxhunt-data: build: context: ../../data dockerfile: Dockerfile.production args: RUST_VERSION: 1.75.0 BUILD_MODE: release container_name: foxhunt-data-prod hostname: foxhunt-data ports: - "8084:8084" volumes: - /opt/foxhunt/config/production.toml:/app/config/config.toml:ro - /opt/foxhunt/data:/app/data:rw - /var/log/foxhunt:/app/logs:rw environment: - RUST_LOG=info - FOXHUNT_CONFIG=/app/config/config.toml - FOXHUNT_ENV=production - POLYGON_API_KEY=${POLYGON_API_KEY} networks: - foxhunt-prod-net cpuset: "16-17" mem_limit: 2g restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8084/health"] interval: 10s timeout: 5s retries: 3 start_period: 30s # Monitoring and Infrastructure Services prometheus: image: prom/prometheus:v2.45.0 container_name: foxhunt-prometheus ports: - "9090:9090" volumes: - ../monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus-data:/prometheus command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--storage.tsdb.retention.time=30d' - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' - '--web.enable-lifecycle' networks: - foxhunt-prod-net restart: unless-stopped grafana: image: grafana/grafana:10.0.0 container_name: foxhunt-grafana ports: - "3000:3000" volumes: - grafana-data:/var/lib/grafana - ../monitoring/grafana/dashboards:/etc/grafana/provisioning/dashboards:ro - ../monitoring/grafana/datasources:/etc/grafana/provisioning/datasources:ro environment: - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin} - GF_USERS_ALLOW_SIGN_UP=false - GF_SERVER_ROOT_URL=http://localhost:3000 networks: - foxhunt-prod-net restart: unless-stopped redis: image: redis:7.0-alpine container_name: foxhunt-redis ports: - "6379:6379" volumes: - redis-data:/data - ../monitoring/redis.conf:/usr/local/etc/redis/redis.conf:ro command: redis-server /usr/local/etc/redis/redis.conf networks: - foxhunt-prod-net # Memory optimization for Redis mem_limit: 1g sysctls: - net.core.somaxconn=65535 restart: unless-stopped networks: foxhunt-prod-net: driver: bridge driver_opts: com.docker.network.bridge.name: foxhunt-br0 ipam: config: - subnet: 172.20.0.0/16 volumes: prometheus-data: driver: local grafana-data: driver: local redis-data: driver: local