services:
  # MongoDB Database Service
  mongodb:
    image: mongo:latest
    container_name: oms-mongodb
    ports:
      - "27717:27017"
    volumes:
      - mongodb_data:/data/db # Persist MongoDB data
    environment:
      MONGO_INITDB_ROOT_USERNAME: oms
      MONGO_INITDB_ROOT_PASSWORD: "oms123." # 密码包含特殊字符，建议用引号
    restart: "no"

  # Redis Cache Service
  redis:
    image: redis:latest
    container_name: oms-redis
    ports:
      - "6379:6379"
    restart: "no"

  # RabbitMQ Message Broker
  rabbitmq:
    image: rabbitmq:3-management-alpine
    container_name: oms-rabbitmq
    ports:
      - "5672:5672" # AMQP 端口
      - "15672:15672" # 管理界面端口
    environment:
      RABBITMQ_DEFAULT_USER: coloring
      RABBITMQ_DEFAULT_PASS: coloring123.
    restart: "no"

  # ClickHouse Columnar Database for Analytics
  clickhouse:
    image: clickhouse/clickhouse-server:latest
    container_name: clickhouse
    ports:
      - "8123:8123" # HTTP 接口
      # - "9000:9000" # 原生 TCP 接口
    volumes:
      - clickhouse_data:/var/lib/clickhouse
    environment:
      CLICKHOUSE_DB: omsdb
      CLICKHOUSE_USER: ckuser
      CLICKHOUSE_PASSWORD: ckpassword
    restart: "no"

  # # Backend Service (OMS)
  # oms:
  #   build:
  #     context: ./oms # Build context is the 'oms' directory
  #     dockerfile: Dockerfile
  #   container_name: oms
  #   ports:
  #     - "3000:3000"
  #   environment:
  #     NODE_ENV: development
  #     PORT: 3000
  #     EVENT_PORT: 3001
  #     MONGO_URI: mongodb://mongodb:27017/omsdb # Docker 内部使用服务名
  #     REMOTE_SYNC_MONGO_URI: mongodb://coloring:coloring123.@gogs.jccytech.cn:7881?authSource=admin
  #     REDIS_URI: redis://redis:6379
  #     RABBITMQ_URL: amqp://coloring:coloring123.@rabbitmq:5672 # Docker 内部使用服务名
  #     RABBITMQ_EXCHANGE: event_exchange
  #     RABBITMQ_LOG_QUEUE: log-event-queue
  #     RABBITMQ_OMS_QUEUE: oms-event-queue # <-- 新增：摄取器队列名
  #     CLICKHOUSE_HOST: http://clickhouse:8123 # <-- 新增：ClickHouse Host
  #     CLICKHOUSE_DATABASE: omsdb # <-- 新增：ClickHouse DB
  #     CLICKHOUSE_USER: ckuser # <-- 新增：ClickHouse 用户
  #     CLICKHOUSE_PASSWORD: ckpassword # <-- 新增：ClickHouse 密码
  #     LOG_DIR: /app/logs/coloring # 日志服务容器内部路径
  #   volumes:
  #     # 开发调试阶段, 挂载整个 oms 目录，但 .dockerignore 会忽略 node_modules 和 omsapp
  #     - ./:/usr/src/app
  #   depends_on:
  #     - mongodb
  #     - redis
  #   restart: "no" # 不自动重启，方便测试和重建

  # # Frontend Nginx Service (OMSApp)
  # omsapp-nginx:
  #   build:
  #     context: ./oms/omsapp # *** 关键变更：构建上下文现在是 ./oms/omsapp
  #     dockerfile: Dockerfile
  #   container_name: omsapp-nginx
  #   ports:
  #     - "80:80"
  #   depends_on:
  #     - oms # 确保后端服务先启动
  #   restart: "no"

# Define volumes for data persistence
volumes:
  mongodb_data:
  clickhouse_data:
