name: xiaoxia-production

# ===========================================
# 日志轮转配置（所有服务共享）
# ===========================================
x-logging: &default-logging
  driver: json-file
  options:
    max-size: "50m"
    max-file: "3"

services:
  postgres-production:
    image: postgres:16
    container_name: xiaoxia-postgres-production
    restart: always
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-xiaoxia_saas}
      POSTGRES_USER: ${POSTGRES_USER:-xiaoxia}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
    ports:
      - "127.0.0.1:${POSTGRES_PORT:-5433}:5432"
    volumes:
      - postgres_production_data:/var/lib/postgresql/data
    networks:
      - xiaoxia-net
    logging: *default-logging
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-xiaoxia} -d ${POSTGRES_DB:-xiaoxia_saas}"]
      interval: 30s
      timeout: 5s
      retries: 5

  redis-production:
    image: redis:7
    container_name: xiaoxia-redis-production
    restart: always
    ports:
      - "127.0.0.1:${REDIS_PORT:-6380}:6379"
    volumes:
      - redis_production_data:/data
    networks:
      - xiaoxia-net
    logging: *default-logging
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 30s
      timeout: 3s
      retries: 5

volumes:
  postgres_production_data:
  redis_production_data:

networks:
  xiaoxia-net:
    external: true
    name: xiaoxia-net-production
