# =============================================================================
# Docker Compose Override Configuration Example
# =============================================================================
# This file provides examples for customizing the Docker Compose setup.
# Copy this file to docker-compose.override.yml and modify as needed.
#
# Usage:
#   cp docker-compose.override.yml.example docker-compose.override.yml
#   # Edit docker-compose.override.yml with your settings
#   docker-compose up -d
#
# IMPORTANT: docker-compose.override.yml is gitignored and will not be committed.
# =============================================================================

# =============================================================================
# Scenario 1: Use External Database and Redis (Recommended for Production)
# =============================================================================
# Use this when you have PostgreSQL and Redis running on the host machine
# or on separate servers.
#
# Prerequisites:
# - PostgreSQL running on host (accessible via host.docker.internal)
# - Redis running on host (accessible via host.docker.internal)
# - Update DATABASE_PORT and REDIS_PORT in .env file if using non-standard ports
#
# Security Notes:
# - Ensure PostgreSQL pg_hba.conf allows connections from Docker network
# - Use strong passwords for database and Redis
# - Consider using SSL/TLS for database connections in production
# =============================================================================

services:
  sub2api:
    # Remove dependencies on containerized postgres/redis
    depends_on: []

    # Enable access to host machine services
    extra_hosts:
      - "host.docker.internal:host-gateway"

    # Override database and Redis connection settings
    environment:
      # PostgreSQL Configuration
      DATABASE_HOST: host.docker.internal
      DATABASE_PORT: "5678"  # Change to your PostgreSQL port
      # DATABASE_USER: postgres  # Uncomment to override
      # DATABASE_PASSWORD: your_password  # Uncomment to override
      # DATABASE_DBNAME: sub2api  # Uncomment to override

      # Redis Configuration
      REDIS_HOST: host.docker.internal
      REDIS_PORT: "6379"  # Change to your Redis port
      # REDIS_PASSWORD: your_redis_password  # Uncomment if Redis requires auth
      # REDIS_DB: 0  # Uncomment to override

  # Disable containerized PostgreSQL
  postgres:
    deploy:
      replicas: 0
    scale: 0

  # Disable containerized Redis
  redis:
    deploy:
      replicas: 0
    scale: 0

# =============================================================================
# Scenario 2: Development with Local Services (Alternative)
# =============================================================================
# Uncomment this section if you want to use the containerized postgres/redis
# but expose their ports for local development tools.
#
# Usage: Comment out Scenario 1 above and uncomment this section.
# =============================================================================

# services:
#   sub2api:
#     # Keep default dependencies
#     pass
#
#   postgres:
#     ports:
#       - "127.0.0.1:5432:5432"  # Expose PostgreSQL on localhost
#
#   redis:
#     ports:
#       - "127.0.0.1:6379:6379"  # Expose Redis on localhost

# =============================================================================
# Scenario 3: Custom Network Configuration
# =============================================================================
# Uncomment if you need to connect to an existing Docker network
# =============================================================================

# networks:
#   default:
#     external: true
#     name: your-existing-network

# =============================================================================
# Scenario 4: Resource Limits (Production)
# =============================================================================
# Uncomment to set resource limits for the sub2api container
# =============================================================================

# services:
#   sub2api:
#     deploy:
#       resources:
#         limits:
#           cpus: '2.0'
#           memory: 2G
#         reservations:
#           cpus: '1.0'
#           memory: 1G

# =============================================================================
# Scenario 5: Custom Volumes
# =============================================================================
# Uncomment to mount additional volumes (e.g., for logs, backups)
# =============================================================================

# services:
#   sub2api:
#     volumes:
#       - ./logs:/app/logs
#       - ./backups:/app/backups

# =============================================================================
# Scenario 6: 启用宿主机 datamanagementd（数据管理）
# =============================================================================
# 说明：
# - datamanagementd 运行在宿主机（systemd 或手动）
# - 主进程固定探测 /tmp/sub2api-datamanagement.sock
# - 需要把宿主机 socket 挂载到容器内同路径
#
# services:
#   sub2api:
#     volumes:
#       - /tmp/sub2api-datamanagement.sock:/tmp/sub2api-datamanagement.sock

# =============================================================================
# Additional Notes
# =============================================================================
# - This file overrides settings in docker-compose.yml
# - Environment variables in .env file take precedence
# - For more information, see: https://docs.docker.com/compose/extends/
# - Check the main README.md for detailed configuration instructions
# =============================================================================
