Spaces:
Running
Running
| # G1: OpenClaw HF Deployment - Dockerfile | |
| # 总目标: HF部署OpenClaw + CC-Switch-Web,持久化、多Agent、飞书/微信 | |
| # 所有程序安装固化在镜像中,重启无需重新安装 | |
| FROM node:22-slim | |
| LABEL maintainer="OpenClaw HF Deploy" | |
| LABEL version="2.1.0" | |
| LABEL description="OpenClaw AI Gateway + CC-Switch-Web, WebDAV/HF backup, Feishu/WeChat integration" | |
| # G1.1: 系统依赖(固化安装) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git \ | |
| openssh-client \ | |
| python3 \ | |
| python3-pip \ | |
| python3-venv \ | |
| curl \ | |
| ca-certificates \ | |
| tar \ | |
| gzip \ | |
| jq \ | |
| vim \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && apt-get clean | |
| # G1.2: Python包(固化安装) | |
| RUN pip3 install --no-cache-dir --break-system-packages \ | |
| huggingface_hub \ | |
| requests \ | |
| schedule | |
| # G1.3: 安装 OpenClaw(固化安装) | |
| RUN npm config set registry https://registry.npmmirror.com && \ | |
| npm install -g openclaw@latest --unsafe-perm --no-audit --no-fund && \ | |
| npx -y @tencent-weixin/openclaw-weixin-cli@latest install && \ | |
| npm config delete registry | |
| # 验证 OpenClaw 安装 | |
| RUN openclaw --version || echo "[WARN] openclaw version check failed" | |
| # 创建工作目录 | |
| WORKDIR /app | |
| # G1.4: 复制应用文件 | |
| COPY backup-manager.py . | |
| COPY config-generator.py . | |
| COPY sync.py . | |
| COPY start-openclaw.sh . | |
| COPY router.js . | |
| COPY scripts/ ./scripts/ | |
| # G1.5: 下载 CC-Switch-Web 预编译二进制 (正式版) | |
| RUN mkdir -p /opt/cc-switch-web && \ | |
| curl -fL https://github.com/Laliet/cc-switch-web/releases/download/v0.11.1/cc-switch-server-linux-x86_64 \ | |
| -o /opt/cc-switch-web/server && \ | |
| chmod +x /opt/cc-switch-web/server | |
| # 设置执行权限 | |
| RUN chmod +x start-openclaw.sh scripts/*.sh | |
| # 创建持久化目录 | |
| RUN mkdir -p /root/.openclaw/{agents,workspace,credentials,sessions,backups,skills,logs} \ | |
| && mkdir -p /root/.cc-switch | |
| # 环境变量默认值 | |
| ENV PORT=18888 \ | |
| OPENCLAW_GATEWAY_PORT=18889 \ | |
| OPENCLAW_STATE_DIR=/root/.openclaw \ | |
| HOME=/root \ | |
| NODE_OPTIONS=--max-old-space-size=512 \ | |
| NPM_CONFIG_REGISTRY=https://registry.npmmirror.com \ | |
| NODE_ENV=production \ | |
| CCSWITCH_PORT=3000 \ | |
| CCSWITCH_HOST=127.0.0.1 \ | |
| CCSWITCH_USERNAME=admin \ | |
| CCSWITCH_PASSWORD="" | |
| # 暴露端口 (Router on 18888) | |
| EXPOSE 18888 | |
| # 启动命令 | |
| CMD ["./start-openclaw.sh"] | |