mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-05-07 06:03:02 +08:00
- #160 Gateway 死循環: _autoPairAndReconnect 后不调用 reconnect() 避免重置计数器 - #165 readConfig 未定义: 替换为内联 fs.readFileSync/writeFileSync - #156 systemd PATH: findOpenclawBin 添加 npm 全局路径, systemd 服务注入 PATH - #159 Docker 双容器冲突: 新增 DISABLE_GATEWAY_SPAWN 环境变量开关 - #151 Gateway 检测冲突: linuxCheckGateway 验证进程名, 拒绝操作非 OpenClaw 进程
166 lines
6.4 KiB
YAML
166 lines
6.4 KiB
YAML
# =============================================================================
|
||
# ClawPanel Docker Compose 配置
|
||
# =============================================================================
|
||
# 使用方法:
|
||
# 1. 快速启动: docker compose up -d
|
||
# 2. 查看日志: docker compose logs -f
|
||
# 3. 停止服务: docker compose down
|
||
# 4. 重新构建: docker compose up -d --build
|
||
# =============================================================================
|
||
|
||
services:
|
||
# ---------------------------------------------------------------------------
|
||
# ClawPanel Web 服务
|
||
# ---------------------------------------------------------------------------
|
||
clawpanel:
|
||
build:
|
||
context: .
|
||
dockerfile: Dockerfile
|
||
# 使用 BuildKit 构建缓存
|
||
cache_from:
|
||
- clawpanel:build-cache
|
||
args:
|
||
- NPM_REGISTRY=https://registry.npmmirror.com
|
||
container_name: clawpanel
|
||
hostname: clawpanel
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 网络配置 - 关键:使用 host 网络模式解决容器内外互通问题
|
||
# -------------------------------------------------------------------------
|
||
# host 模式:容器共享宿主机网络命名空间
|
||
# 优点:
|
||
# 1. 容器可以直接访问宿主机上的服务(如 Gateway)
|
||
# 2. 避免端口映射的复杂性
|
||
# 3. 性能更好(无额外网络层)
|
||
# 注意:使用 host 模式后,ports 配置无效
|
||
# -------------------------------------------------------------------------
|
||
network_mode: host
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 端口映射(仅在 network_mode 为 default 时生效)
|
||
# 如果你想用 bridge 模式而不是 host 模式,注释上面一行,取消下面注释
|
||
# -------------------------------------------------------------------------
|
||
# ports:
|
||
# - "1420:1420" # ClawPanel Web 界面
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 卷挂载 - 数据持久化
|
||
# -------------------------------------------------------------------------
|
||
volumes:
|
||
# OpenClaw 配置目录 - 关键!
|
||
# 包含 openclaw.json, mcp.json, agents/, devices/ 等
|
||
- ~/.openclaw:/root/.openclaw
|
||
# ClawPanel 数据目录(可选,用于存储临时文件)
|
||
- ./data:/app/data
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 环境变量
|
||
# -------------------------------------------------------------------------
|
||
environment:
|
||
- NODE_ENV=production
|
||
# OpenClaw Gateway 地址(如果 Gateway 不在本地,修改为实际地址)
|
||
# 注意:host 模式下直接使用 localhost 或 127.0.0.1
|
||
- OPENCLAW_URL=http://127.0.0.1:18789
|
||
# 双容器模式下禁止面板自动启动 Gateway(取消注释)
|
||
# - DISABLE_GATEWAY_SPAWN=1
|
||
# 如果需要代理(取消注释并修改为实际代理地址)
|
||
# - HTTP_PROXY=http://host.docker.internal:7890
|
||
# - HTTPS_PROXY=http://host.docker.internal:7890
|
||
# 时区设置
|
||
- TZ=Asia/Shanghai
|
||
# 确保 HOME 环境变量正确
|
||
- HOME=/root
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 重启策略
|
||
# -------------------------------------------------------------------------
|
||
restart: unless-stopped
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 健康检查
|
||
# -------------------------------------------------------------------------
|
||
healthcheck:
|
||
test: ["CMD", "curl", "-f", "http://localhost:1420/"]
|
||
interval: 30s
|
||
timeout: 5s
|
||
retries: 3
|
||
start_period: 15s
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 安全配置
|
||
# -------------------------------------------------------------------------
|
||
# 使用读安全选项减少攻击面
|
||
security_opt:
|
||
- no-new-privileges:true
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 资源限制(可选,取消注释以限制资源使用)
|
||
# -------------------------------------------------------------------------
|
||
# deploy:
|
||
# resources:
|
||
# limits:
|
||
# cpus: '1.0'
|
||
# memory: 1G
|
||
# reservations:
|
||
# cpus: '0.5'
|
||
# memory: 512M
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 日志配置
|
||
# -------------------------------------------------------------------------
|
||
logging:
|
||
driver: "json-file"
|
||
options:
|
||
max-size: "10m"
|
||
max-file: "3"
|
||
|
||
# -------------------------------------------------------------------------
|
||
# 依赖(可选,如果 Gateway 在另一个容器中)
|
||
# -------------------------------------------------------------------------
|
||
# depends_on:
|
||
# gateway:
|
||
# condition: service_healthy
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# OpenClaw Gateway 服务(可选,取消注释以启用)
|
||
# ---------------------------------------------------------------------------
|
||
# gateway:
|
||
# image: node:22-alpine
|
||
# container_name: openclaw-gateway
|
||
# hostname: openclaw-gateway
|
||
# network_mode: host
|
||
# volumes:
|
||
# - ~/.openclaw:/root/.openclaw
|
||
# environment:
|
||
# - TZ=Asia/Shanghai
|
||
# restart: unless-stopped
|
||
# command: >
|
||
# sh -c "npm install -g @qingchencloud/openclaw-zh --registry https://registry.npmmirror.com &&
|
||
# openclaw init 2>/dev/null || true &&
|
||
# openclaw gateway start --foreground"
|
||
# healthcheck:
|
||
# test: ["CMD", "curl", "-f", "http://localhost:18789/health"]
|
||
# interval: 30s
|
||
# timeout: 5s
|
||
# retries: 3
|
||
# logging:
|
||
# driver: "json-file"
|
||
# options:
|
||
# max-size: "10m"
|
||
# max-file: "3"
|
||
|
||
# =============================================================================
|
||
# 网络配置(使用 host 模式时不需要)
|
||
# =============================================================================
|
||
# networks:
|
||
# default:
|
||
# name: clawpanel-network
|
||
# driver: bridge
|
||
|
||
# =============================================================================
|
||
# 卷配置
|
||
# =============================================================================
|
||
# volumes:
|
||
# openclaw-config:
|
||
# name: clawpanel-openclaw-config
|