services:

  openclaw-gateway:
    image: ${OPENCLAW_IMAGE:-openclaw:local}
    environment:
      HOME: /home/node
      TERM: xterm-256color
      OPENCLAW_GATEWAY_TOKEN: ${OPENCLAW_GATEWAY_TOKEN}
      CLAUDE_AI_SESSION_KEY: ${CLAUDE_AI_SESSION_KEY:-}
      CLAUDE_WEB_SESSION_KEY: ${CLAUDE_WEB_SESSION_KEY:-}
      CLAUDE_WEB_COOKIE: ${CLAUDE_WEB_COOKIE:-}
      GMAIL_ADDRESS: ${GMAIL_ADDRESS:-}
      GMAIL_APP_PASSWORD: ${GMAIL_APP_PASSWORD:-}
      OPENAI_API_KEY: ${OPENAI_API_KEY:-}
      ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
      TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN:-}
      DISCORD_BOT_TOKEN: ${DISCORD_BOT_TOKEN:-}
      XDG_CONFIG_HOME: /home/node/.openclaw
      GOG_KEYRING_PASSWORD: ${GOG_KEYRING_PASSWORD:-}
      GOG_ACCOUNT: ${GOG_ACCOUNT:-}
      PLAYWRIGHT_BROWSERS_PATH: /home/node/.cache/ms-playwright
      BRAVE_API_KEY: ${BRAVE_API_KEY:-}
      GOPLACES_API_KEY: ${GOPLACES_API_KEY:-}
      GH_ISSUES_API_KEY: ${GH_ISSUES_API_KEY:-}
      N8N_API_KEY: ${N8N_API_KEY:-}
      CONDUCTOR_API_TOKEN: ${CONDUCTOR_API_TOKEN:-}
      PCLOUD_CLIENT_ID: ${PCLOUD_CLIENT_ID:-}
      PCLOUD_CLIENT_SECRET: ${PCLOUD_CLIENT_SECRET:-}
      PCLOUD_ACCESS_TOKEN: ${PCLOUD_ACCESS_TOKEN:-}
      PCLOUD_API_HOST: ${PCLOUD_API_HOST:-api.pcloud.com}
    volumes:
      - openclaw_config:/home/node/.openclaw
      - openclaw_workspace:/home/node/.openclaw/workspace
      - openclaw_logs:/home/node/.openclaw/logs
      - /usr/local/bin/gog:/usr/local/bin/gog:ro
      - /root/.config/gogcli:/home/node/.openclaw/gogcli
    ports:
      - "${OPENCLAW_GATEWAY_PORT:-18789}:18789"
      - "${OPENCLAW_BRIDGE_PORT:-18790}:18790"
    networks:
      - default
      - clawbot_shared
    shm_size: '256m'
    init: true
    restart: unless-stopped
    command: ["sh", "-c", "ln -sfn /app/skills/gog /home/node/.openclaw/workspace/skills/gog && node dist/index.js gateway --bind lan --port 18789"]

  openclaw-cli:
    image: ${OPENCLAW_IMAGE:-openclaw:local}
    environment:
      HOME: /home/node
      TERM: xterm-256color
      OPENCLAW_GATEWAY_TOKEN: ${OPENCLAW_GATEWAY_TOKEN}
      OPENCLAW_GATEWAY_URL: ws://openclaw-gateway:18789
      BROWSER: echo
      OPENAI_API_KEY: ${OPENAI_API_KEY:-}
      ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
    volumes:
      - openclaw_config:/home/node/.openclaw
      - openclaw_workspace:/home/node/.openclaw/workspace
      - openclaw_logs:/home/node/.openclaw/logs
      - openclaw_node_config:/home/node/.config
    stdin_open: true
    tty: true
    init: true
    entrypoint: ["node", "dist/index.js"]

  file-server:
    image: nginx:alpine
    container_name: openclaw-file-server
    restart: unless-stopped
    ports:
      - "8088:80"
    volumes:
      - openclaw_workspace:/srv/files:ro
      - ./file-server-nginx.conf:/etc/nginx/conf.d/default.conf:ro
    networks:
      - default

  backup:
    image: python:3.11-alpine
    environment:
      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:-}
      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:-}
      AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION:-us-east-2}
      S3_BUCKET: ${S3_BUCKET:-}
      S3_ENDPOINT: ${S3_ENDPOINT:-}
    volumes:
      - openclaw_config:/backup/config:ro
      - openclaw_workspace:/backup/workspace:ro
      - openclaw_logs:/backup/logs:ro
      - ./scripts/backup.sh:/backup.sh:ro
    entrypoint: ["/bin/sh", "/backup.sh"]
    restart: "no"
    profiles: ["backup"]

networks:
  clawbot_shared:
    external: true

volumes:
  openclaw_config:
    external: true
  openclaw_workspace:
    external: true
  openclaw_logs:
    external: true
  openclaw_node_config:
    external: true
