# Docker Compose for production
# Use: docker compose -f docker-compose.yml -f docker-compose.prod.yml up

services:
  app:
    # Production-specific settings
    environment:
      - NODE_ENV=production
      - DOCKER_ENV=true
    
    # Load production environment variables
    env_file:
      - .env.production
    
    # Production command
    command: ["npm", "start"]
    
    # Only expose necessary port
    ports:
      - "9000:3000"
    
    # Remove network_mode: host to avoid port conflicts
    # Use bridge network instead
    networks:
      - default
    
    # Production volumes (no source code mounting)
    volumes:
      - ./screenshots:/app/screenshots
      - ./videos:/app/videos
      - ./.tradingview-session:/app/.tradingview-session
      - ./prisma:/app/prisma
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
    
    # Production labels
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.trading-bot.rule=Host(`trading-bot.local`)"
    
    # Resource limits for production
    deploy:
      resources:
        limits:
          memory: 2G
        reservations:
          memory: 1G
    
    # Restart policy
    restart: unless-stopped
    
    # Health check
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
