joeshen commited on
Commit
452ec8b
·
verified ·
1 Parent(s): 548adb2

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +219 -0
Dockerfile ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:22-slim
2
+
3
+ # Install system dependencies
4
+ RUN apt-get update && \
5
+ apt-get install -y python3 git tzdata && \
6
+ apt-get install -y libnss3 \
7
+ libatk1.0-0 \
8
+ libatk-bridge2.0-0 \
9
+ libcups2 \
10
+ libxkbcommon0 \
11
+ libxcomposite1 \
12
+ libxdamage1 \
13
+ libxfixes3 \
14
+ libxrandr2 \
15
+ libgbm1 \
16
+ libasound2 \
17
+ libpangocairo-1.0-0 \
18
+ libpango-1.0-0 \
19
+ libgtk-3-0 && \
20
+ rm -rf /var/lib/apt/lists/*
21
+
22
+ # Install OpenClaw globally
23
+ RUN npm install -g openclaw@2026.3.13
24
+ RUN npm install -g clawhub
25
+
26
+ #
27
+ RUN npm install -g playwright && playwright install chromium
28
+
29
+ # 安装clawport
30
+ #RUN npm install -g clawport-ui
31
+
32
+ # 启动前禁用 device-pair
33
+ #RUN openclaw devices approve --all
34
+ #RUN openclaw plugins disable device-pair
35
+ #RUN openclaw approvals allowlist add *
36
+
37
+ # Create config directory
38
+ RUN mkdir -p /root/.openclaw
39
+
40
+ # Environment variables
41
+ ENV TZ=Asia/Shanghai
42
+ ENV PORT=18789
43
+ ENV OPENCLAW_GATEWAY_MODE=local
44
+ #ENV OPENCLAW_GATEWAY_PASSWORD=${OPENCLAW_GATEWAY_PASSWORD}
45
+
46
+ # Expose port
47
+ EXPOSE 18789
48
+
49
+
50
+ # Create startup script
51
+ RUN cat << 'EOF' > /usr/local/bin/start-openclaw
52
+ #!/bin/bash
53
+ set -e
54
+ set -x
55
+
56
+ # Check required environment variable
57
+ if [ -z "$GEMINI_APIKEY" ]; then
58
+ echo "ERROR: GEMINI_APIKEY is not set. Exiting."
59
+ exit 1
60
+ fi
61
+
62
+ # Create required directories
63
+ mkdir -p /root/.openclaw/agents/main/agent
64
+ mkdir -p /root/.openclaw/agents/main/sessions
65
+ mkdir -p /root/.openclaw/credentials
66
+
67
+ # Remove auth-profiles.json to force env usage
68
+ rm -f /root/.openclaw/agents/main/agent/auth-profiles.json
69
+
70
+ # 强制重新生成配置
71
+ rm -f /root/.openclaw/openclaw.json
72
+
73
+ cat << 'INNEREOF' > /root/.openclaw/devices.json
74
+ {
75
+ "trusted": ["*"]
76
+ }
77
+ INNEREOF
78
+
79
+ # Generate config if not exists
80
+ if [ ! -f /root/.openclaw/openclaw.json ]; then
81
+ cat << INNEREOF > /root/.openclaw/openclaw.json
82
+ {
83
+ "env": {
84
+ "GOOGLE_API_KEY": "${GEMINI_APIKEY}",
85
+ "GEMINI_API_KEY": "${GEMINI_APIKEY}",
86
+ "GOOGLE_GENERATIVE_AI_API_KEY": "${GEMINI_APIKEY}",
87
+ "PALM_API_KEY": "${GEMINI_APIKEY}"
88
+ },
89
+ "gateway": {
90
+ "mode": "${OPENCLAW_GATEWAY_MODE}",
91
+ "bind": "lan",
92
+ "port": ${PORT},
93
+ "trustedProxies": ["0.0.0.0/0"],
94
+ "auth": {
95
+ "mode": "token",
96
+ "token": "${OPENCLAW_GATEWAY_PASSWORD}"
97
+ },
98
+ "controlUi": {
99
+ "allowInsecureAuth": true,
100
+ "allowedOrigins": [
101
+ "*"
102
+ ]
103
+ }
104
+ },
105
+ "models": {
106
+ "mode": "merge",
107
+ "providers": {
108
+ "custom-api-nvidia-kimi-k25": {
109
+ "baseUrl": "${OPENAI_API_BASE}",
110
+ "apiKey": "${OPENAI_API_KEY}",
111
+ "api": "openai-completions",
112
+ "models": [
113
+ {
114
+ "id": "${MODEL}",
115
+ "name": "${MODEL} (Custom Provider)",
116
+ "reasoning": false,
117
+ "input": [
118
+ "text"
119
+ ],
120
+ "cost": {
121
+ "input": 0,
122
+ "output": 0,
123
+ "cacheRead": 0,
124
+ "cacheWrite": 0
125
+ },
126
+ "contextWindow": 256000,
127
+ "maxTokens": 8192
128
+ }
129
+ ]
130
+ }
131
+ }
132
+ },
133
+ "agents": {
134
+ "defaults": {
135
+ "model": {
136
+ "primary": "custom-api-nvidia-kimi-k25/${MODEL}"
137
+ },
138
+ "models": {
139
+ "custom-api-nvidia-kimi-k25/${MODEL}": {
140
+ "alias": "custom-api-nvidia-kimi-k25"
141
+ }
142
+ },
143
+ }
144
+ }
145
+ }
146
+ INNEREOF
147
+ fi
148
+
149
+ # Fix permissions
150
+ chmod 700 /root/.openclaw
151
+ chmod 600 /root/.openclaw/openclaw.json || true
152
+ chmod 600 /root/.openclaw/agents/main/agent/auth-profiles.json 2>/dev/null || true
153
+
154
+ # Run doctor
155
+ openclaw doctor --fix || true
156
+
157
+ # 添加dingtalk
158
+ #openclaw plugins install @mjand66/openclaw-dingtalk
159
+ #openclaw config set channels.dingtalk.allowFrom '["*"]'
160
+ #openclaw config set channels.dingtalk.groupAllowFrom '["*"]'
161
+ #openclaw config set channels.dingtalk.dmPolicy "allowlist"
162
+ #openclaw config set channels.dingtalk.groupPolicy "allowlist"
163
+ #openclaw config set channels.dingtalk.clientId "dinglkmevdghzv6nzqyh"
164
+ #openclaw config set channels.dingtalk.clientSecret "${DINGTALK_AIBOT_SECRET}"
165
+ #openclaw config set channels.dingtalk.robotCode "dinglkmevdghzv6nzqyh"
166
+ #openclaw config set channels.dingtalk.messageType "markdown"
167
+ #openclaw config set channels.dingtalk.enabled true
168
+
169
+ # 添加wecom
170
+ #openclaw plugins install @wecom/wecom-openclaw-plugin@1.0.11
171
+ #openclaw config set channels.wecom.botId "${WECOM_AIBOT_ID}"
172
+ #openclaw config set channels.wecom.secret "${WECOM_AIBOT_SECRET}"
173
+ #openclaw config set channels.wecom.dmPolicy "allowlist"
174
+ #openclaw config set channels.wecom.allowFrom '["*"]'
175
+ #openclaw config set channels.wecom.enabled true
176
+
177
+ # 添加discord
178
+ #openclaw config set channels.discord.token "${DISCORD_AIBOT_SECRET}"
179
+ #openclaw config set channels.discord.groupPolicy "open"
180
+ #openclaw config set channels.discord.streaming "off"
181
+ #openclaw config set channels.discord.enabled true
182
+
183
+ # 添加feishu
184
+ #openclaw config set channels.feishu.domain "feishu"
185
+ #openclaw config set channels.feishu.appId "cli_a732de0347bad00b"
186
+ #openclaw config set channels.feishu.appSecret "${FEISHU_AIBOT_SECRET}"
187
+ #openclaw config set channels.feishu.connectionMode "websocket"
188
+ #openclaw config set channels.feishu.groupPolicy "allowlist"
189
+ #openclaw config set channels.feishu.allowFrom '["*"]'
190
+ #openclaw config set channels.feishu.groupAllowFrom '["*"]'
191
+ #openclaw config set channels.feishu.enabled true
192
+
193
+
194
+ # 自动批准
195
+ #openclaw devices approve --all || true
196
+
197
+ echo "Starting OpenClaw gateway on port ${PORT}..."
198
+
199
+ #openclaw approvals allowlist add *
200
+
201
+ #openclaw doctor --fix
202
+
203
+ #exec openclaw start --port ${PORT}
204
+ #exec openclaw agent run --name main
205
+ exec openclaw gateway run --port ${PORT}
206
+ #clawport dev --port 3000 &
207
+ #openclaw gateway run --port ${PORT} &
208
+ #openclaw devices list &
209
+ #sleep 30 # 确保 gateway 已启动
210
+ #openclaw devices approve --all || true
211
+ #openclaw dashboard --no-open &
212
+ #clawport dev --port 3000 &
213
+ #wait -n
214
+
215
+ EOF
216
+
217
+ RUN chmod +x /usr/local/bin/start-openclaw
218
+
219
+ CMD ["/usr/local/bin/start-openclaw"]