Spaces:
Running
Running
| FROM node:22-bookworm | |
| # Install Bun (required for build scripts) and curl (health check) | |
| RUN curl -fsSL https://bun.sh/install | bash | |
| ENV PATH="/root/.bun/bin:${PATH}" | |
| RUN corepack enable | |
| WORKDIR /app | |
| # Clone official OpenClaw repo and checkout v2026.3.1 | |
| RUN git clone https://github.com/openclaw/openclaw.git . && \ | |
| git fetch --tags && \ | |
| git checkout v2026.3.1 | |
| # Install dependencies | |
| RUN pnpm install --no-frozen-lockfile | |
| # Build project | |
| ENV OPENCLAW_A2UI_SKIP_MISSING=1 | |
| RUN pnpm build | |
| # Build Control UI | |
| ENV OPENCLAW_PREFER_PNPM=1 | |
| RUN pnpm ui:build | |
| ENV NODE_ENV=production | |
| # 强制北京时间(解决 HF Spaces 默认 UTC 导致 agent 汇报时间错误) | |
| ENV TZ=Asia/Shanghai | |
| RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone | |
| # Install openclaw-china channels plugin and update to latest | |
| RUN node openclaw.mjs plugins install @openclaw-china/channels || \ | |
| (echo "❌ Failed to install @openclaw-china/channels plugin" && exit 1) | |
| RUN node openclaw.mjs plugins update channels || \ | |
| echo "⚠️ Failed to update channels plugin, using installed version" | |
| # Install wecom-app-ops skill (optional but recommended for wecom-app operations) | |
| RUN mkdir -p /root/.openclaw/skills && \ | |
| if [ -d "/root/.openclaw/extensions/openclaw-china/extensions/wecom-app/skills/wecom-app-ops" ]; then \ | |
| cp -a /root/.openclaw/extensions/openclaw-china/extensions/wecom-app/skills/wecom-app-ops /root/.openclaw/skills/ && \ | |
| echo "✅ wecom-app-ops skill installed"; \ | |
| else \ | |
| echo "⚠️ wecom-app-ops skill not found, skipping"; \ | |
| fi | |
| # Install Chromium and dependencies for agent-browser | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends chromium \ | |
| libxcb-shm0 libx11-xcb1 libx11-6 libxcb1 libxext6 libxrandr2 \ | |
| libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libgtk-3-0 \ | |
| libpangocairo-1.0-0 libpango-1.0-0 libatk1.0-0 libcairo-gobject2 \ | |
| libcairo2 libgdk-pixbuf-2.0-0 libxrender1 libasound2 libfreetype6 \ | |
| libfontconfig1 libdbus-1-3 libnss3 libnspr4 libatk-bridge2.0-0 \ | |
| libdrm2 libxkbcommon0 libatspi2.0-0 libcups2 libxshmfence1 libgbm1 && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Install agent-browser and Playwright | |
| RUN npm install -g agent-browser@latest playwright | |
| ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium | |
| ENV PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright | |
| # Install agent-browser skill from ClawHub | |
| RUN npx -y clawhub@latest install agent-browser --force || echo "agent-browser skill install attempted" | |
| # Install ClawMate Companion plugin via manual git clone (避免 npx 交互式提示导致构建失败) | |
| RUN echo "📦 Installing ClawMate Companion..." && \ | |
| git clone --depth 1 https://github.com/BytePioneer-AI/clawmate.git /tmp/clawmate && \ | |
| mkdir -p /root/.openclaw/extensions && \ | |
| cp -r /tmp/clawmate/packages/clawmate-companion /root/.openclaw/extensions/clawmate-companion && \ | |
| cd /root/.openclaw/extensions/clawmate-companion && \ | |
| npm install --omit=dev --no-audit --no-fund && \ | |
| rm -rf /tmp/clawmate && \ | |
| echo "✅ ClawMate Companion 安装成功" | |
| # ============================================================ | |
| # 敏感文件不再 COPY 进镜像,改为运行时从 Supabase 下载 | |
| # 以下只预创建目录结构,文件由 entrypoint.sh 下载填充 | |
| # ============================================================ | |
| # patches 目标目录(clawmate 补丁) | |
| RUN mkdir -p /root/.openclaw/extensions/clawmate-companion/src/core \ | |
| && mkdir -p /root/.openclaw/extensions/clawmate-companion/skills/clawmate-companion | |
| # characters 目标目录(Maggie 角色资源) | |
| RUN mkdir -p /root/.openclaw/extensions/clawmate-companion/skills/clawmate-companion/assets/characters/maggie/images | |
| # workspace 目标目录(角色设定、任务文档等) | |
| RUN mkdir -p /root/.openclaw/workspace/memory | |
| # cron 目标目录 | |
| RUN mkdir -p /root/.openclaw/cron | |
| # config 目标目录 | |
| RUN mkdir -p /root/.openclaw | |
| # Make openclaw CLI available globally (agent exec tool needs it for `openclaw status` etc.) | |
| RUN printf '#!/bin/sh\nexec node /app/openclaw.mjs "$@"\n' > /usr/local/bin/openclaw && chmod +x /usr/local/bin/openclaw | |
| # Copy and set entrypoint script | |
| COPY entrypoint.sh /app/entrypoint.sh | |
| RUN chmod +x /app/entrypoint.sh | |
| # HF Spaces requires port 7860 | |
| EXPOSE 7860 | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ | |
| CMD curl -f http://localhost:7860/ || exit 1 | |
| # Use entrypoint to inject secrets at runtime | |
| CMD ["/app/entrypoint.sh"] | |