Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +7 -12
Dockerfile
CHANGED
|
@@ -23,7 +23,7 @@ ENV TZ=Asia/Shanghai \
|
|
| 23 |
OPENCLAW_SECURITY_STRICT=false \
|
| 24 |
NODE_TLS_REJECT_UNAUTHORIZED=0
|
| 25 |
|
| 26 |
-
# 5. 同步引擎 (
|
| 27 |
RUN echo 'import os, sys, tarfile, time\n\
|
| 28 |
from huggingface_hub import HfApi, hf_hub_download\n\
|
| 29 |
from datetime import datetime, timedelta\n\
|
|
@@ -51,20 +51,17 @@ def restore():\n\
|
|
| 51 |
with tarfile.open(path, "r:gz") as tar: tar.extractall(path=base_dir)\n\
|
| 52 |
print(f"--- [Sync] ✅ 恢复成功! (日期: {day}) ---")\n\
|
| 53 |
return True\n\
|
| 54 |
-
print("--- [Sync] ℹ️ 未发现最近 5 天内的备份文件
|
| 55 |
except Exception as e:\n\
|
| 56 |
-
print(f"--- [Sync] ❌ 恢复
|
| 57 |
\n\
|
| 58 |
def backup():\n\
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
return\n\
|
| 63 |
try:\n\
|
| 64 |
target_dir = "/root/.openclaw"\n\
|
| 65 |
-
if not os.path.exists(target_dir):\n\
|
| 66 |
-
print(f"--- [Sync] ⚠️ 目录 {target_dir} 不存在,取消备份 ---")\n\
|
| 67 |
-
return\n\
|
| 68 |
day = datetime.now().strftime("%Y-%m-%d")\n\
|
| 69 |
name = f"backup_{day}.tar.gz"\n\
|
| 70 |
print(f"--- [Sync] 📦 正在压缩配置文件夹... ---")\n\
|
|
@@ -88,7 +85,6 @@ ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime\n\
|
|
| 88 |
echo \"Asia/Shanghai\" > /etc/timezone\n\
|
| 89 |
\n\
|
| 90 |
mkdir -p /root/.openclaw\n\
|
| 91 |
-
# 执行恢复并打印日志\n\
|
| 92 |
python3 /usr/local/bin/sync.py restore\n\
|
| 93 |
\n\
|
| 94 |
CLEAN_BASE=\$(echo \"\$OPENAI_API_BASE\" | sed \"s|/chat/completions||g\" | sed \"s|/v1/|/v1|g\")\n\
|
|
@@ -118,7 +114,6 @@ module.exports = {\n\
|
|
| 118 |
}\n\
|
| 119 |
EOF\n\
|
| 120 |
\n\
|
| 121 |
-
# 定时备份逻辑\n\
|
| 122 |
(while true; do \n\
|
| 123 |
sleep 1800; \n\
|
| 124 |
python3 /usr/local/bin/sync.py backup; \n\
|
|
|
|
| 23 |
OPENCLAW_SECURITY_STRICT=false \
|
| 24 |
NODE_TLS_REJECT_UNAUTHORIZED=0
|
| 25 |
|
| 26 |
+
# 5. 同步引擎 (已修复引号嵌套导致的 SyntaxError)
|
| 27 |
RUN echo 'import os, sys, tarfile, time\n\
|
| 28 |
from huggingface_hub import HfApi, hf_hub_download\n\
|
| 29 |
from datetime import datetime, timedelta\n\
|
|
|
|
| 51 |
with tarfile.open(path, "r:gz") as tar: tar.extractall(path=base_dir)\n\
|
| 52 |
print(f"--- [Sync] ✅ 恢复成功! (日期: {day}) ---")\n\
|
| 53 |
return True\n\
|
| 54 |
+
print("--- [Sync] ℹ️ 未发现最近 5 天内的备份文件 ---")\n\
|
| 55 |
except Exception as e:\n\
|
| 56 |
+
print(f"--- [Sync] ❌ 恢复失败: {str(e)} ---")\n\
|
| 57 |
\n\
|
| 58 |
def backup():\n\
|
| 59 |
+
now_ts = datetime.now().strftime("%H:%M:%S")\n\
|
| 60 |
+
print(f"--- [Sync] 📤 启动定时备份任务 [{now_ts}] ---")\n\
|
| 61 |
+
if not repo_id or not token: return\n\
|
|
|
|
| 62 |
try:\n\
|
| 63 |
target_dir = "/root/.openclaw"\n\
|
| 64 |
+
if not os.path.exists(target_dir): return\n\
|
|
|
|
|
|
|
| 65 |
day = datetime.now().strftime("%Y-%m-%d")\n\
|
| 66 |
name = f"backup_{day}.tar.gz"\n\
|
| 67 |
print(f"--- [Sync] 📦 正在压缩配置文件夹... ---")\n\
|
|
|
|
| 85 |
echo \"Asia/Shanghai\" > /etc/timezone\n\
|
| 86 |
\n\
|
| 87 |
mkdir -p /root/.openclaw\n\
|
|
|
|
| 88 |
python3 /usr/local/bin/sync.py restore\n\
|
| 89 |
\n\
|
| 90 |
CLEAN_BASE=\$(echo \"\$OPENAI_API_BASE\" | sed \"s|/chat/completions||g\" | sed \"s|/v1/|/v1|g\")\n\
|
|
|
|
| 114 |
}\n\
|
| 115 |
EOF\n\
|
| 116 |
\n\
|
|
|
|
| 117 |
(while true; do \n\
|
| 118 |
sleep 1800; \n\
|
| 119 |
python3 /usr/local/bin/sync.py backup; \n\
|