| FROM node:22-bookworm | |
| # Install Bun (required for build scripts) | |
| RUN curl -fsSL https://bun.sh/install | bash | |
| ENV PATH="/root/.bun/bin:${PATH}" | |
| # 启用 pnpm | |
| RUN corepack enable | |
| WORKDIR /app | |
| ARG CLAWDBOT_DOCKER_APT_PACKAGES="" | |
| RUN if [ -n "$CLAWDBOT_DOCKER_APT_PACKAGES" ]; then \ | |
| apt-get update && \ | |
| DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $CLAWDBOT_DOCKER_APT_PACKAGES && \ | |
| apt-get clean && \ | |
| rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \ | |
| fi | |
| # 安装 git(用于克隆仓库) | |
| RUN apt-get update && \ | |
| DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git && \ | |
| apt-get clean && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # 克隆源码 | |
| RUN git clone https://github.com/clawdbot/clawdbot.git ./ | |
| # 安装依赖并构建 | |
| RUN pnpm install --frozen-lockfile | |
| RUN pnpm build | |
| RUN npm i -g clawdbot | |
| # Force pnpm for UI build (Bun may fail on ARM/Synology architectures) | |
| ENV CLAWDBOT_PREFER_PNPM=1 | |
| RUN pnpm ui:install | |
| RUN pnpm ui:build | |
| # 设置生产环境 | |
| ENV NODE_ENV=production | |
| # 暴露默认端口(根据项目文档为 8888) | |
| EXPOSE 18789 | |
| # 启动命令(需确认 package.json 中的启动脚本,通常为 serve 或 preview) | |
| # CMD ["node", "dist/index.js"] | |
| CMD ["clawdbot onboard"] |