From e6dab8c3dd245ae4453b97ce3489b983afe89fbb Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 16 Apr 2026 16:07:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Dockerfile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 60 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index f26403c..35f88da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,37 +2,49 @@ FROM dcloud-registry.cn-beijing.cr.aliyuncs.com/dcloud/rdk-claw USER root -# 安装 tini 进程管理器 -RUN curl -fsSL https://github.com/krallin/tini/releases/download/v0.19.0/tini-static -o /home/node/tini && chmod +x /home/node/tini +RUN set -eux; \ + if ! getent group 1001 >/dev/null; then groupadd -g 1001 user; fi; \ + if ! id -u 1001 >/dev/null 2>&1; then useradd -m -u 1001 -g 1001 -s /bin/bash user; fi + +RUN curl -fsSL https://github.com/krallin/tini/releases/download/v0.19.0/tini-static -o /usr/local/bin/tini \ + && chmod +x /usr/local/bin/tini + +RUN apt-get update \ + && apt-get install -y --no-install-recommends socat \ + && rm -rf /var/lib/apt/lists/* -# 安装 skillhub RUN curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash -RUN cp /root/.local/bin/skillhub /usr/local/bin/skillhub && chmod +x /usr/local/bin/skillhub && mkdir -p /workspace/default && chmod 1777 /workspace/default +RUN cp /root/.local/bin/skillhub /usr/local/bin/skillhub \ + && chmod +x /usr/local/bin/skillhub -# 创建 gateway-watchdog.sh 守护脚本 -RUN printf '%s\n' \ - '#!/usr/bin/env bash' \ - 'set -euo pipefail' \ - '' \ - 'while true; do' \ - ' echo "Starting gateway..."' \ - ' openclaw gateway --allow-unconfigured' \ - ' EXIT_CODE=$?' \ - ' echo "Gateway exited with code $EXIT_CODE, restarting in 2s..."' \ - ' sleep 2' \ - 'done' > /usr/local/bin/gateway-watchdog.sh && chmod +x /usr/local/bin/gateway-watchdog.sh +RUN set -eux; \ + mkdir -p /workspace/default /home/user/.openclaw/identity /run/e2b; \ + chmod 1777 /workspace/default /run/e2b; \ + chown -R 1001:1001 /home/user /workspace/default + +RUN ln -sfn /workspace/default/.openclaw /home/user/.openclaw + +RUN cat > /usr/local/bin/gateway-watchdog.sh <<'EOF' && chmod +x /usr/local/bin/gateway-watchdog.sh +#!/usr/bin/env bash +set -uo pipefail + +while true; do + echo "[watchdog] starting gateway..." + OUTPUT="$(openclaw gateway --allow-unconfigured 2>&1)" + EXIT_CODE=$? + [ -n "$OUTPUT" ] && printf "%s\n" "$OUTPUT" + echo "[watchdog] gateway exited with code ${EXIT_CODE}, restart in 2s" + sleep 2 +done +EOF -# 替换 SOUL.md 和 IDENTITY.md COPY rdk-claw/SOUL.md /app/docs/reference/templates/SOUL.md COPY rdk-claw/IDENTITY.md /app/docs/reference/templates/IDENTITY.md - -# 添加 node-remote-connect skill COPY rdk-claw/node-remote-connect /app/skills/node-remote-connect +RUN chown -R 1001:1001 /app/skills/node-remote-connect -# 确保权限正确 -RUN chown -R node:node /app/skills/node-remote-connect - -USER node +ENV HOME=/home/user +USER 1001:1001 ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["/home/node/tini", "--", "/usr/local/bin/gateway-watchdog.sh"] \ No newline at end of file +CMD ["/usr/local/bin/tini", "--", "/usr/local/bin/gateway-watchdog.sh"]