superX432 commited on
Commit
2164841
·
verified ·
1 Parent(s): 20ed3a2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -17
Dockerfile CHANGED
@@ -2,7 +2,6 @@
2
  FROM node:22-slim
3
 
4
  # 1. 安装系统依赖
5
- # 包含:git (拉取依赖), openssh-client (解决构建报错), build-essential/g++/make (编译原生模块), python3 (运行同步脚本)
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  git openssh-client build-essential python3 python3-pip \
8
  g++ make ca-certificates \
@@ -12,7 +11,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
12
  RUN pip3 install --no-cache-dir huggingface_hub --break-system-packages
13
 
14
  # 3. 构建环境优化
15
- # 修复 Git 证书问题并将所有 SSH 协议重定向为 HTTPS
16
  RUN update-ca-certificates && \
17
  git config --global http.sslVerify false && \
18
  git config --global url."https://github.com/".insteadOf ssh://git@github.com/
@@ -26,7 +24,6 @@ ENV PORT=7860 \
26
  HOME=/root
27
 
28
  # 6. 核心同步引擎 (sync.py)
29
- # 针对 OpenClaw 新版 MEMORY.md 机制进行了全路径覆盖
30
  RUN echo 'import os, sys, tarfile\n\
31
  from huggingface_hub import HfApi, hf_hub_download\n\
32
  from datetime import datetime, timedelta\n\
@@ -60,7 +57,6 @@ def backup():\n\
60
  name = f"backup_{day}.tar.gz"\n\
61
  print(f"--- [SYNC] 正在执行全量备份: {name} ---")\n\
62
  with tarfile.open(name, "w:gz") as tar:\n\
63
- # 路径说明:sessions(网关历史), workspace(记忆文件), agents(配置), memory(旧版目录)\n\
64
  for target in ["sessions", "workspace", "agents", "memory", "openclaw.json"]:\n\
65
  full_path = f"/root/.openclaw/{target}"\n\
66
  if os.path.exists(full_path):\n\
@@ -74,35 +70,29 @@ if __name__ == "__main__":\n\
74
  else: restore()' > /usr/local/bin/sync.py
75
 
76
  # 7. 容器入口脚本 (start-openclaw)
77
- # 负责恢复数据 -> 生成配置 -> 启动网关 -> 定时备份
78
- # 7. 容器入口脚本 (Updated for Gemini & Security Fix)
79
  RUN echo "#!/bin/bash\n\
80
  set -e\n\
81
  mkdir -p /root/.openclaw/sessions\n\
82
  mkdir -p /root/.openclaw/workspace\n\
83
  \n\
84
- # 启动前执行数据恢复\n\
85
  python3 /usr/local/bin/sync.py restore\n\
86
  \n\
87
- # 生成 openclaw.json 配置文件\n\
88
  cat > /root/.openclaw/openclaw.json <<EOF\n\
89
  {\n\
90
  \"models\": {\n\
91
  \"providers\": {\n\
92
  \"google\": {\n\
93
- \"apiKey\": \"\$GEMINI_API_KEY\",\n\
 
94
  \"api\": \"google-generative-ai\",\n\
95
- \"models\": [\n\
96
- { \"id\": \"\$MODEL\", \"name\": \"Gemini Pro\", \"contextWindow\": 1000000 }\n\
97
- ]\n\
98
  }\n\
99
  }\n\
100
  },\n\
101
  \"agents\": { \"defaults\": { \"model\": { \"primary\": \"google/\$MODEL\" } } },\n\
102
  \"gateway\": {\n\
103
- \"mode\": \"local\", \n\
104
- \"bind\": \"loopback\", \n\
105
- \"port\": \$PORT,\n\
106
  \"trustedProxies\": [\"0.0.0.0/0\"],\n\
107
  \"auth\": { \"mode\": \"token\", \"token\": \"\$OPENCLAW_GATEWAY_PASSWORD\" },\n\
108
  \"controlUi\": { \"allowInsecureAuth\": true }\n\
@@ -110,10 +100,9 @@ cat > /root/.openclaw/openclaw.json <<EOF\n\
110
  }\n\
111
  EOF\n\
112
  \n\
113
- # 启动定时备份进程\n\
114
  (while true; do sleep 10800; python3 /usr/local/bin/sync.py backup; done) &\n\
115
  \n\
116
- # 启动 OpenClaw 网关 (Force Loopback to skip security error)\n\
117
  exec openclaw gateway run --port \$PORT --bind 127.0.0.1\n\
118
  " > /usr/local/bin/start-openclaw && chmod +x /usr/local/bin/start-openclaw
119
 
 
2
  FROM node:22-slim
3
 
4
  # 1. 安装系统依赖
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  git openssh-client build-essential python3 python3-pip \
7
  g++ make ca-certificates \
 
11
  RUN pip3 install --no-cache-dir huggingface_hub --break-system-packages
12
 
13
  # 3. 构建环境优化
 
14
  RUN update-ca-certificates && \
15
  git config --global http.sslVerify false && \
16
  git config --global url."https://github.com/".insteadOf ssh://git@github.com/
 
24
  HOME=/root
25
 
26
  # 6. 核心同步引擎 (sync.py)
 
27
  RUN echo 'import os, sys, tarfile\n\
28
  from huggingface_hub import HfApi, hf_hub_download\n\
29
  from datetime import datetime, timedelta\n\
 
57
  name = f"backup_{day}.tar.gz"\n\
58
  print(f"--- [SYNC] 正在执行全量备份: {name} ---")\n\
59
  with tarfile.open(name, "w:gz") as tar:\n\
 
60
  for target in ["sessions", "workspace", "agents", "memory", "openclaw.json"]:\n\
61
  full_path = f"/root/.openclaw/{target}"\n\
62
  if os.path.exists(full_path):\n\
 
70
  else: restore()' > /usr/local/bin/sync.py
71
 
72
  # 7. 容器入口脚本 (start-openclaw)
 
 
73
  RUN echo "#!/bin/bash\n\
74
  set -e\n\
75
  mkdir -p /root/.openclaw/sessions\n\
76
  mkdir -p /root/.openclaw/workspace\n\
77
  \n\
 
78
  python3 /usr/local/bin/sync.py restore\n\
79
  \n\
80
+ # 生成 openclaw.json (Updated for Gemini compatibility while keeping your var names)\n\
81
  cat > /root/.openclaw/openclaw.json <<EOF\n\
82
  {\n\
83
  \"models\": {\n\
84
  \"providers\": {\n\
85
  \"google\": {\n\
86
+ \"baseUrl\": \"https://generativelanguage.googleapis.com\",\n\
87
+ \"apiKey\": \"\$OPENAI_API_KEY\",\n\
88
  \"api\": \"google-generative-ai\",\n\
89
+ \"models\": [{ \"id\": \"\$MODEL\", \"name\": \"Gemini\", \"contextWindow\": 1000000 }]\n\
 
 
90
  }\n\
91
  }\n\
92
  },\n\
93
  \"agents\": { \"defaults\": { \"model\": { \"primary\": \"google/\$MODEL\" } } },\n\
94
  \"gateway\": {\n\
95
+ \"mode\": \"local\", \"bind\": \"loopback\", \"port\": \$PORT,\n\
 
 
96
  \"trustedProxies\": [\"0.0.0.0/0\"],\n\
97
  \"auth\": { \"mode\": \"token\", \"token\": \"\$OPENCLAW_GATEWAY_PASSWORD\" },\n\
98
  \"controlUi\": { \"allowInsecureAuth\": true }\n\
 
100
  }\n\
101
  EOF\n\
102
  \n\
 
103
  (while true; do sleep 10800; python3 /usr/local/bin/sync.py backup; done) &\n\
104
  \n\
105
+ # Using --bind 127.0.0.1 and loopback in config to bypass the Security Doctor error\n\
106
  exec openclaw gateway run --port \$PORT --bind 127.0.0.1\n\
107
  " > /usr/local/bin/start-openclaw && chmod +x /usr/local/bin/start-openclaw
108