wd21 commited on
Commit
cdf49d2
·
verified ·
1 Parent(s): 6b8e0fb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -62
Dockerfile CHANGED
@@ -1,9 +1,16 @@
1
  FROM node:22-slim
2
 
 
3
  RUN apt-get update && apt-get install -y --no-install-recommends \
4
  git ca-certificates build-essential python3 python3-pip curl \
 
 
 
5
  && rm -rf /var/lib/apt/lists/*
6
 
 
 
 
7
  RUN pip3 install --no-cache-dir huggingface_hub --break-system-packages
8
 
9
  RUN npm install -g openclaw@latest --unsafe-perm
@@ -14,73 +21,14 @@ ENV PORT=7860 \
14
  OPENCLAW_GATEWAY_MODE=local \
15
  HOME=/root
16
 
17
- # 完整备份恢复脚本 sync.py
18
  RUN cat > /usr/local/bin/sync.py << 'SYNC_EOF'
19
- import os, sys, tarfile
20
- from huggingface_hub import HfApi, hf_hub_download
21
- from datetime import datetime, timedelta
22
- import subprocess
23
- import time
24
-
25
- api = HfApi()
26
- repo_id = os.getenv("HF_DATASET")
27
- token = os.getenv("HF_TOKEN")
28
-
29
- def restore():
30
- try:
31
- print(f"--- [SYNC] 启动恢复流程, 目标仓库: {repo_id} ---")
32
- if not repo_id or not token:
33
- print("--- [SYNC] 跳过恢复: 未配置 HF_DATASET 或 HF_TOKEN ---")
34
- return False
35
- files = api.list_repo_files(repo_id=repo_id, repo_type="dataset", token=token)
36
- now = datetime.now()
37
- for i in range(5):
38
- day = (now - timedelta(days=i)).strftime("%Y-%m-%d")
39
- name = f"backup_{day}.tar.gz"
40
- if name in files:
41
- print(f"--- [SYNC] 发现备份文件: {name}, 正在下载... ---")
42
- path = hf_hub_download(repo_id=repo_id, filename=name, repo_type="dataset", token=token)
43
- with tarfile.open(path, "r:gz") as tar:
44
- tar.extractall(path="/root/.openclaw/")
45
- print(f"--- [SYNC] 恢复成功! 数据已覆盖至 /root/.openclaw/ ---")
46
- return True
47
- print("--- [SYNC] 未找到最近 5 天的备份包 ---")
48
- except Exception as e:
49
- print(f"--- [SYNC] 恢复异常: {e} ---")
50
-
51
- def backup():
52
- try:
53
- day = datetime.now().strftime("%Y-%m-%d")
54
- name = f"backup_{day}.tar.gz"
55
- print(f"--- [SYNC] 正在执行全量备份: {name} ---")
56
- with tarfile.open(name, "w:gz") as tar:
57
- for target in ["sessions", "workspace", "agents", "memory", "openclaw.json", "wechat-data"]:
58
- full_path = f"/root/.openclaw/{target}"
59
- if os.path.exists(full_path):
60
- tar.add(full_path, arcname=target)
61
- api.upload_file(path_or_fileobj=name, path_in_repo=name, repo_id=repo_id, repo_type="dataset", token=token)
62
- print(f"--- [SYNC] 备份上传成功! ---")
63
- for _ in range(3):
64
- try:
65
- result = subprocess.run(["openclaw", "wechat", "send", "--to=me", f"备份成功: {name}"], capture_output=True, timeout=10)
66
- if result.returncode == 0:
67
- break
68
- except Exception:
69
- pass
70
- time.sleep(5)
71
- except Exception as e:
72
- print(f"--- [SYNC] 备份失败: {e} ---")
73
-
74
- if __name__ == "__main__":
75
- if len(sys.argv) > 1 and sys.argv[1] == "backup":
76
- backup()
77
- else:
78
- restore()
79
  SYNC_EOF
80
 
81
  RUN chmod +x /usr/local/bin/sync.py
82
 
83
- # 启动脚本 start-openclaw
84
  RUN cat > /usr/local/bin/start-openclaw << 'EOF'
85
  #!/bin/bash
86
  set -e
@@ -136,6 +84,7 @@ if [ -n "$TELEGRAM_GROUP_IDS" ]; then
136
  GROUPS_CONFIG="$GROUPS_CONFIG }"
137
  fi
138
 
 
139
  cat > /root/.openclaw/openclaw.json <<EOF2
140
  {
141
  "models": {
@@ -187,6 +136,12 @@ cat > /root/.openclaw/openclaw.json <<EOF2
187
  "jitter": 0.1
188
  }$GROUPS_CONFIG
189
  }
 
 
 
 
 
 
190
  }
191
  }
192
  EOF2
 
1
  FROM node:22-slim
2
 
3
+ # ========= 1. 安装系统依赖 + Chromium 浏览器 =========
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  git ca-certificates build-essential python3 python3-pip curl \
6
+ chromium \
7
+ # Chromium 运行所需额外库(避免沙盒/渲染问题)
8
+ libnss3 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libgbm1 libasound2 \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # 设置 Chromium 可执行路径(OpenClaw / Puppeteer 会自动读取)
12
+ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
13
+
14
  RUN pip3 install --no-cache-dir huggingface_hub --break-system-packages
15
 
16
  RUN npm install -g openclaw@latest --unsafe-perm
 
21
  OPENCLAW_GATEWAY_MODE=local \
22
  HOME=/root
23
 
24
+ # 完整备份恢复脚本 sync.py(保持不变)
25
  RUN cat > /usr/local/bin/sync.py << 'SYNC_EOF'
26
+ ...(此处省略原内容,保持原样)...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  SYNC_EOF
28
 
29
  RUN chmod +x /usr/local/bin/sync.py
30
 
31
+ # 启动脚本 start-openclaw(需要修改 openclaw.json 生成部分)
32
  RUN cat > /usr/local/bin/start-openclaw << 'EOF'
33
  #!/bin/bash
34
  set -e
 
84
  GROUPS_CONFIG="$GROUPS_CONFIG }"
85
  fi
86
 
87
+ # ========= 2. 在 openclaw.json 中加入 browser 配置 =========
88
  cat > /root/.openclaw/openclaw.json <<EOF2
89
  {
90
  "models": {
 
136
  "jitter": 0.1
137
  }$GROUPS_CONFIG
138
  }
139
+ },
140
+ "browser": {
141
+ "enabled": true,
142
+ "headless": true,
143
+ "noSandbox": true,
144
+ "defaultProfile": "openclaw"
145
  }
146
  }
147
  EOF2