Download Dockerfile from zooking/wanzi1010: direct link, hf CLI and curl.
- Browser
- Download file 3.66 kB
-
https://huggingface.co/spaces/zooking/wanzi1010/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/zooking/wanzi1010/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/zooking/wanzi1010/resolve/main/Dockerfile
3.66 kB
| FROM node:22-slim | |
| # 1. 系统依赖 | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git openssh-client build-essential python3 python3-pip \ | |
| g++ make ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN pip3 install --no-cache-dir huggingface_hub --break-system-packages | |
| # 2. 修复构建环境 | |
| RUN update-ca-certificates && \ | |
| git config --global http.sslVerify false && \ | |
| git config --global url."https://github.com/".insteadOf ssh://git@github.com/ | |
| # 3. 安装 OpenClaw | |
| RUN npm install -g openclaw@latest --unsafe-perm | |
| ENV PORT=7860 \ | |
| OPENCLAW_GATEWAY_MODE=local \ | |
| HOME=/root | |
| # 4. 备份恢复脚本 | |
| RUN echo 'import os, sys, tarfile\n\ | |
| from huggingface_hub import HfApi, hf_hub_download\n\ | |
| from datetime import datetime, timedelta\n\ | |
| api = HfApi()\n\ | |
| repo_id = os.getenv("HF_DATASET")\n\ | |
| token = os.getenv("HF_TOKEN")\n\ | |
| def restore():\n\ | |
| try:\n\ | |
| files = api.list_repo_files(repo_id=repo_id, repo_type="dataset", token=token)\n\ | |
| now = datetime.now()\n\ | |
| for i in range(5):\n\ | |
| day = (now - timedelta(days=i)).strftime("%Y-%m-%d")\n\ | |
| name = f"backup_{day}.tar.gz"\n\ | |
| if name in files:\n\ | |
| path = hf_hub_download(repo_id=repo_id, filename=name, repo_type="dataset", token=token)\n\ | |
| with tarfile.open(path, "r:gz") as tar:\n\ | |
| tar.extractall(path="/root/.openclaw/")\n\ | |
| return True\n\ | |
| except Exception as e: print(f"Restore Error: {e}")\n\ | |
| def backup():\n\ | |
| try:\n\ | |
| day = datetime.now().strftime("%Y-%m-%d")\n\ | |
| name = f"backup_{day}.tar.gz"\n\ | |
| with tarfile.open(name, "w:gz") as tar:\n\ | |
| tar.add("/root/.openclaw/sessions", arcname="sessions")\n\ | |
| tar.add("/root/.openclaw/openclaw.json", arcname="openclaw.json")\n\ | |
| api.upload_file(path_or_fileobj=name, path_in_repo=name, repo_id=repo_id, repo_type="dataset", token=token)\n\ | |
| except Exception as e: print(f"Backup Error: {e}")\n\ | |
| if __name__ == "__main__":\n\ | |
| if len(sys.argv) > 1 and sys.argv[1] == "backup": backup()\n\ | |
| else: restore()' > /usr/local/bin/sync.py | |
| # 5. 启动脚本 (重点修复 auth 结构) | |
| RUN echo "#!/bin/bash\n\ | |
| set -e\n\ | |
| mkdir -p /root/.openclaw/sessions\n\ | |
| python3 /usr/local/bin/sync.py restore\n\ | |
| \n\ | |
| CLEAN_BASE=\$(echo \"\$OPENAI_API_BASE\" | sed \"s|/chat/completions||g\" | sed \"s|/v1/|/v1|g\" | sed \"s|/v1\$|/v1|g\")\n\ | |
| \n\ | |
| cat > /root/.openclaw/openclaw.json <<EOF\n\ | |
| {\n\ | |
| \"models\": {\n\ | |
| \"providers\": {\n\ | |
| \"siliconflow\": {\n\ | |
| \"baseUrl\": \"\$CLEAN_BASE\",\n\ | |
| \"apiKey\": \"\$OPENAI_API_KEY\",\n\ | |
| \"api\": \"openai-completions\",\n\ | |
| \"models\": [{ \"id\": \"\$MODEL\", \"name\": \"DeepSeek\", \"contextWindow\": 128000 }]\n\ | |
| }\n\ | |
| }\n\ | |
| },\n\ | |
| \"agents\": { \"defaults\": { \"model\": { \"primary\": \"siliconflow/\$MODEL\" } } },\n\ | |
| \"gateway\": {\n\ | |
| \"mode\": \"local\",\n\ | |
| \"bind\": \"lan\",\n\ | |
| \"port\": \$PORT,\n\ | |
| \"trustedProxies\": [\"0.0.0.0/0\", \"10.0.0.0/8\", \"172.16.0.0/12\", \"192.168.0.0/16\"],\n\ | |
| \"auth\": {\n\ | |
| \"mode\": \"token\",\n\ | |
| \"token\": \"\Fokuaguo230165Ning\"\n\ | |
| },\n\ | |
| \"controlUi\": {\n\ | |
| \"allowInsecureAuth\": true,\n\ | |
| \"gatewayToken\": \"\Fokuaguo230165Ning\"\n\ | |
| }\n\ | |
| }\n\ | |
| }\n\ | |
| EOF\n\ | |
| \n\ | |
| (while true; do sleep 21600; python3 /usr/local/bin/sync.py backup; done) &\n\ | |
| \n\ | |
| openclaw doctor --fix\n\ | |
| exec openclaw gateway run --port \$PORT\n\ | |
| " > /usr/local/bin/start-openclaw && chmod +x /usr/local/bin/start-openclaw | |
| EXPOSE 7860 | |
| CMD ["/usr/local/bin/start-openclaw"] |