# AI+合规智能中枢 - 基础设施部署配置
# Milvus向量数据库 + MinIO对象存储 + Redis缓存

services:
  # Milvus向量数据库 (Standalone模式)
  milvus:
    image: milvusdb/milvus:v2.4-latest
    container_name: milvus-standalone
    ports:
      - "19530:19530"  # SDK连接端口
      - "9091:9091"    # 健康检查端口
    environment:
      ETCD_USE_EMBED: "true"
      COMMON_LOG_LEVEL: "info"
    volumes:
      - milvus_data:/var/lib/milvus
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
      interval: 30s
      timeout: 10s
      retries: 5
    restart: unless-stopped
    command: ["milvus", "run", "standalone"]

  # MinIO对象存储
  minio:
    image: minio/minio:latest
    container_name: minio
    ports:
      - "9000:9000"   # API端口
      - "9001:9001"   # Console端口
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin123
    volumes:
      - minio_data:/data
    command: server /data --console-address ":9001"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 10s
      retries: 5
    restart: unless-stopped

  # Redis缓存
  redis:
    image: redis:7-alpine
    container_name: redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 30s
      timeout: 10s
      retries: 5
    restart: unless-stopped

  # PostgreSQL数据库 (启用 DOCUMENT_REPOSITORY_BACKEND=postgres 时使用；
  # 合规分析历史记录 Direction B、DOCX 报告下载及 Finding Chat 持久化 Direction C 均依赖此服务)
  postgres:
    image: postgres:15-alpine
    container_name: postgres
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: compliance
      POSTGRES_PASSWORD: compliance123
      POSTGRES_DB: compliance_db
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U compliance -d compliance_db"]
      interval: 30s
      timeout: 10s
      retries: 5
    restart: unless-stopped

volumes:
  milvus_data:
  minio_data:
  redis_data:
  postgres_data:

networks:
  default:
    name: compliance-network