-
Notifications
You must be signed in to change notification settings - Fork 322
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
165 lines (151 loc) · 6.39 KB
/
docker-compose.yml
File metadata and controls
165 lines (151 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# =============================================================================
# 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