version: "3.8"

services:
  # ============================================================
  #  小红书 AI 爆文工坊（主应用）
  # ============================================================
  xhs-autobot:
    build: .
    container_name: xhs-autobot
    restart: unless-stopped
    ports:
      - "7860:7860"
    volumes:
      # 配置文件挂载（首次请从 config.example.json 复制并填写）
      - ./config.json:/app/config.json
      # 工作目录（导出的文案 & 图片）
      - ./xhs_workspace:/app/xhs_workspace
    environment:
      - GRADIO_SERVER_NAME=0.0.0.0
      - GRADIO_SERVER_PORT=7860
    depends_on:
      xhs-mcp:
        condition: service_started
    networks:
      - xhs-net

  # ============================================================
  #  xiaohongshu-mcp 服务（小红书 API 代理）
  # ============================================================
  xhs-mcp:
    image: node:20-slim
    container_name: xhs-mcp
    restart: unless-stopped
    ports:
      - "18060:18060"
    working_dir: /app
    # 首次启动自动安装并运行 xiaohongshu-mcp
    command: >
      sh -c "
        npm install -g xiaohongshu-mcp &&
        npx xiaohongshu-mcp --port 18060 --host 0.0.0.0
      "
    volumes:
      # cookies 持久化（登录后保留会话）
      - xhs-mcp-data:/root/.xiaohongshu-mcp
    networks:
      - xhs-net

  # ============================================================
  #  Stable Diffusion WebUI（可选 — 取消注释启用）
  #  ⚠ 需要 NVIDIA GPU + nvidia-docker
  # ============================================================
  # sd-webui:
  #   image: ghcr.io/AUTOMATIC1111/stable-diffusion-webui:latest
  #   container_name: sd-webui
  #   restart: unless-stopped
  #   ports:
  #     - "7861:7860"
  #   volumes:
  #     - sd-models:/app/models
  #     - sd-outputs:/app/outputs
  #   deploy:
  #     resources:
  #       reservations:
  #         devices:
  #           - driver: nvidia
  #             count: all
  #             capabilities: [gpu]
  #   command: ["python", "launch.py", "--api", "--listen"]
  #   networks:
  #     - xhs-net

volumes:
  xhs-mcp-data:
  # sd-models:
  # sd-outputs:

networks:
  xhs-net:
    driver: bridge
