# ============================================================
# OpenClaw Docker Compose 配置
# 
# 使用方法:
#   1. 使用 ~/.openclaw/env + ~/.openclaw/openclaw.json（与命令行安装一致）
#   2. 运行: docker-compose up -d
#   3. 升级后建议: openclaw update --restart && openclaw doctor --fix && openclaw plugins update --all
#   4. 查看日志: docker-compose logs -f
# ============================================================

version: '3.8'

services:
  openclaw:
    build: .
    image: openclaw:latest
    container_name: openclaw
    restart: unless-stopped
    
    # 环境变量（可选，优先级高于配置文件）
    environment:
      - TZ=Asia/Shanghai
      # 可以通过环境变量设置敏感信息
      # - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      # - OPENAI_API_KEY=${OPENAI_API_KEY}
      # - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
    
    # 端口映射
    ports:
      - "18789:18789"
    
    # 卷挂载
    volumes:
      # 配置和数据持久化
      - ~/.openclaw:/root/.openclaw
      # 可选：挂载自定义技能目录
      # - ./custom-skills:/root/.openclaw/skills
    
    # 健康检查
    healthcheck:
      test: ["CMD", "openclaw", "health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    
    # 日志配置
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    
    # 网络配置
    networks:
      - openclaw-network

  # 可选：Ollama 本地模型服务
  # 取消注释以启用本地 AI 模型
  # ollama:
  #   image: ollama/ollama:latest
  #   container_name: ollama
  #   restart: unless-stopped
  #   ports:
  #     - "11434:11434"
  #   volumes:
  #     - ollama-data:/root/.ollama
  #   networks:
  #     - openclaw-network
  #   deploy:
  #     resources:
  #       reservations:
  #         devices:
  #           - driver: nvidia
  #             count: all
  #             capabilities: [gpu]

networks:
  openclaw-network:
    driver: bridge

# volumes:
#   ollama-data:
