# 生产环境配置覆盖
services:
  qaup-postgres:
    # 生产环境不暴露数据库端口
    ports: []
    # 增强资源配置
    deploy:
      resources:
        limits:
          memory: 2G
          cpus: '2.0'
        reservations:
          memory: 1G
          cpus: '1.0'
    # 生产环境日志配置
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "5"

  qaup-redis:
    # 生产环境不暴露 Redis 端口
    ports: []
    # 启用持久化
    command: ["redis-server", "--appendonly", "yes", "--maxmemory", "256mb", "--maxmemory-policy", "allkeys-lru"]
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "3"

  qaup-app:
    # 生产环境不直接暴露应用端口
    ports: []
    # 生产环境变量
    environment:
      SPRING_PROFILES_ACTIVE: prod
      LOG_PATH: /app/logs
      # 安全配置
      MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE: health,info,metrics
      MANAGEMENT_ENDPOINT_HEALTH_SHOW_DETAILS: when_authorized
      # 性能配置
      JVM_OPTS: -Dname=qaup-admin.jar -Duser.timezone=Asia/Shanghai -server -Xms1g -Xmx2g -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:+UseStringDeduplication -XX:+OptimizeStringConcat
    # 增强资源配置
    deploy:
      resources:
        limits:
          memory: 3G
          cpus: '2.0'
        reservations:
          memory: 2G
          cpus: '1.5'
    logging:
      driver: "json-file"
      options:
        max-size: "200m"
        max-file: "10"

  qaup-nginx:
    # 生产环境端口配置
    ports:
      - "80:80"
      - "443:443"
    # 生产环境配置
    environment:
      NGINX_PORT: 80
      SERVER_NAME: ${PRODUCTION_DOMAIN:-localhost}
      API_PREFIX: /prod-api
      BACKEND_HOST: qaup-app
      BACKEND_PORT: 8080
      MAX_UPLOAD_SIZE: 50M
      STATIC_CACHE_TIME: 30d
    # SSL 证书挂载（如果需要）
    volumes:
      - nginx_logs:/var/log/nginx
      - nginx_cache:/var/cache/nginx
      - ${SSL_CERT_DIR:-./ssl}:/etc/nginx/ssl:ro
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "5"

# 生产环境网络配置
networks:
  qaup-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.30.0.0/16
