FROM node:22-slim # ─── 1. 系统基础依赖 ────────────────────────────────────────────────────────── RUN apt-get update && apt-get install -y --no-install-recommends \ git openssh-client build-essential python3 python3-pip \ make g++ curl wget ca-certificates tini procps jq unzip zip \ locales \ && sed -i '/zh_CN.UTF-8/s/^# //g' /etc/locale.gen \ && locale-gen \ && rm -rf /var/lib/apt/lists/* # ─── 2. Python 工具 ─────────────────────────────────────────────────────────── RUN pip3 install --no-cache-dir huggingface_hub requests httpx --break-system-packages # ─── 3. 全局安装 OpenClaw ───────────────────────────────────────────────────── RUN npm install -g openclaw@latest --registry https://registry.npmmirror.com && npm cache clean --force # ─── 4. 环境变量 ────────────────────────────────────────────────────────────── ENV LANG=zh_CN.UTF-8 \ LANGUAGE=zh_CN:zh \ LC_ALL=zh_CN.UTF-8 \ HOME=/home/node \ PORT=7860 \ NPM_CONFIG_REGISTRY=https://registry.npmmirror.com # ─── 5. Git 强制 HTTPS ──────────────────────────────────────────────────────── RUN git config --global url."https://github.com/".insteadOf ssh://git@github.com/ \ && git config --global url."https://github.com/".insteadOf git@github.com: # ─── 6. 工作目录 & 脚本 ────────────────────────────────────────────────────── WORKDIR /app COPY --chown=node:node sync.py . COPY --chown=node:node start-openclaw.sh . RUN chmod +x start-openclaw.sh # ─── 7. 权限调整 ────────────────────────────────────────────────────────────── RUN mkdir -p /home/node/.openclaw \ && chown -R node:node /home/node # ─── 8. 切换至非 root 用户(内置 node 用户 UID = 1000,符合 HF 规范)───────── USER 1000 # ─── 9. 暴露端口并启动 ─────────────────────────────────────────────────────── EXPOSE 7860 ENTRYPOINT ["tini", "--"] CMD ["./start-openclaw.sh"]