|
| 1 | +# NemoClaw sandbox base image — expensive, rarely-changing layers. |
| 2 | +# |
| 3 | +# Contains: node:22-slim, apt packages, gosu, user/group setup, |
| 4 | +# .openclaw directory structure, OpenClaw CLI, and PyYAML. |
| 5 | +# |
| 6 | +# Built on main merges and pushed to GHCR. The production Dockerfile |
| 7 | +# layers PR-specific code (plugin, blueprint, config) on top. |
| 8 | +# |
| 9 | +# ── Why these layers are safe to cache ────────────────────────────────── |
| 10 | +# |
| 11 | +# Everything in this file is either pinned to an exact version or is |
| 12 | +# structural (users, directories, symlinks) that doesn't depend on |
| 13 | +# NemoClaw application code. Specifically: |
| 14 | +# |
| 15 | +# node:22-slim — pinned by sha256 digest, checked weekly by |
| 16 | +# docker-pin-check.yaml |
| 17 | +# apt packages — pinned to exact Debian bookworm versions |
| 18 | +# gosu 1.19 — pinned release + per-arch sha256 checksum |
| 19 | +# gateway/sandbox — OS users and groups; names and UIDs are a |
| 20 | +# users stable contract with OpenShell |
| 21 | +# .openclaw dirs — directory structure + symlinks are dictated by |
| 22 | +# + symlinks the OpenClaw CLI layout; new dirs are additive |
| 23 | +# (add them here and rebuild) |
| 24 | +# openclaw CLI — pinned to exact npm version (e.g., 2026.3.11) |
| 25 | +# pyyaml — pinned to exact pip version (6.0.3) |
| 26 | +# |
| 27 | +# Nothing here references NemoClaw plugin source, blueprint files, |
| 28 | +# startup scripts, or build-time config (model, provider, auth token). |
| 29 | +# Those all live in the production Dockerfile's thin top layers. |
| 30 | +# |
| 31 | +# ── When to rebuild ───────────────────────────────────────────────────── |
| 32 | +# |
| 33 | +# The base-image.yaml workflow rebuilds automatically on main merges that |
| 34 | +# touch this file. You need to edit this file (triggering a rebuild) when: |
| 35 | +# |
| 36 | +# 1. OpenClaw CLI version bump — change the openclaw@version below |
| 37 | +# 2. New apt package needed — add it to the apt-get install list |
| 38 | +# 3. gosu upgrade — update URL, checksum, and version |
| 39 | +# 4. node:22-slim digest rotated — update-docker-pin.sh updates both |
| 40 | +# Dockerfile and Dockerfile.base |
| 41 | +# 5. New .openclaw subdirectory — add mkdir + symlink below |
| 42 | +# 6. PyYAML or other pip dep bump — change the version below |
| 43 | +# |
| 44 | +# For ad-hoc rebuilds (e.g., security patch), use workflow_dispatch on |
| 45 | +# the base-image workflow. |
| 46 | +# |
| 47 | +# Expected rebuild frequency: every few weeks to months, driven mostly |
| 48 | +# by OpenClaw CLI version bumps or the weekly docker-pin-check. |
| 49 | +# ──────────────────────────────────────────────────────────────────────── |
| 50 | + |
| 51 | +FROM node:22-slim@sha256:4f77a690f2f8946ab16fe1e791a3ac0667ae1c3575c3e4d0d4589e9ed5bfaf3d |
| 52 | + |
| 53 | +ENV DEBIAN_FRONTEND=noninteractive |
| 54 | + |
| 55 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 56 | + python3=3.11.2-1+b1 \ |
| 57 | + python3-pip=23.0.1+dfsg-1 \ |
| 58 | + python3-venv=3.11.2-1+b1 \ |
| 59 | + curl=7.88.1-10+deb12u14 \ |
| 60 | + git=1:2.39.5-0+deb12u3 \ |
| 61 | + ca-certificates=20230311+deb12u1 \ |
| 62 | + iproute2=6.1.0-3 \ |
| 63 | + iptables=1.8.9-2 \ |
| 64 | + libcap2-bin=1:2.66-4+deb12u2+b2 \ |
| 65 | + && rm -rf /var/lib/apt/lists/* |
| 66 | + |
| 67 | +# gosu for privilege separation (gateway vs sandbox user). |
| 68 | +# Install from GitHub release with checksum verification instead of |
| 69 | +# Debian bookworm's ancient 1.14 (2020). Pinned to 1.19 (2025-09). |
| 70 | +# hadolint ignore=DL4006 |
| 71 | +RUN arch="$(dpkg --print-architecture)" \ |
| 72 | + && case "$arch" in \ |
| 73 | + amd64) gosu_asset="gosu-amd64"; gosu_sha256="52c8749d0142edd234e9d6bd5237dff2d81e71f43537e2f4f66f75dd4b243dd0" ;; \ |
| 74 | + arm64) gosu_asset="gosu-arm64"; gosu_sha256="3a8ef022d82c0bc4a98bcb144e77da714c25fcfa64dccc57f6aba7ae47ff1a44" ;; \ |
| 75 | + *) echo "Unsupported architecture for gosu: $arch" >&2; exit 1 ;; \ |
| 76 | + esac \ |
| 77 | + && curl -fsSL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.19/${gosu_asset}" \ |
| 78 | + && echo "${gosu_sha256} /usr/local/bin/gosu" | sha256sum -c - \ |
| 79 | + && chmod +x /usr/local/bin/gosu \ |
| 80 | + && gosu --version |
| 81 | + |
| 82 | +# Create sandbox user (matches OpenShell convention) and gateway user. |
| 83 | +# The gateway runs as 'gateway' so the 'sandbox' user (agent) cannot |
| 84 | +# kill it or restart it with a tampered HOME/config. |
| 85 | +RUN groupadd -r gateway && useradd -r -g gateway -d /sandbox -s /usr/sbin/nologin gateway \ |
| 86 | + && groupadd -r sandbox && useradd -r -g sandbox -d /sandbox -s /bin/bash sandbox \ |
| 87 | + && mkdir -p /sandbox/.nemoclaw \ |
| 88 | + && chown -R sandbox:sandbox /sandbox |
| 89 | + |
| 90 | +# Split .openclaw into immutable config dir + writable state dir. |
| 91 | +# The policy makes /sandbox/.openclaw read-only via Landlock, so the agent |
| 92 | +# cannot modify openclaw.json, auth tokens, or CORS settings. Writable |
| 93 | +# state (agents, plugins, etc.) lives in .openclaw-data, reached via symlinks. |
| 94 | +# Ref: https://github.com/NVIDIA/NemoClaw/issues/514 |
| 95 | +RUN mkdir -p /sandbox/.openclaw-data/agents/main/agent \ |
| 96 | + /sandbox/.openclaw-data/extensions \ |
| 97 | + /sandbox/.openclaw-data/workspace \ |
| 98 | + /sandbox/.openclaw-data/skills \ |
| 99 | + /sandbox/.openclaw-data/hooks \ |
| 100 | + /sandbox/.openclaw-data/identity \ |
| 101 | + /sandbox/.openclaw-data/devices \ |
| 102 | + /sandbox/.openclaw-data/canvas \ |
| 103 | + /sandbox/.openclaw-data/cron \ |
| 104 | + && mkdir -p /sandbox/.openclaw \ |
| 105 | + && ln -s /sandbox/.openclaw-data/agents /sandbox/.openclaw/agents \ |
| 106 | + && ln -s /sandbox/.openclaw-data/extensions /sandbox/.openclaw/extensions \ |
| 107 | + && ln -s /sandbox/.openclaw-data/workspace /sandbox/.openclaw/workspace \ |
| 108 | + && ln -s /sandbox/.openclaw-data/skills /sandbox/.openclaw/skills \ |
| 109 | + && ln -s /sandbox/.openclaw-data/hooks /sandbox/.openclaw/hooks \ |
| 110 | + && ln -s /sandbox/.openclaw-data/identity /sandbox/.openclaw/identity \ |
| 111 | + && ln -s /sandbox/.openclaw-data/devices /sandbox/.openclaw/devices \ |
| 112 | + && ln -s /sandbox/.openclaw-data/canvas /sandbox/.openclaw/canvas \ |
| 113 | + && ln -s /sandbox/.openclaw-data/cron /sandbox/.openclaw/cron \ |
| 114 | + && touch /sandbox/.openclaw-data/update-check.json \ |
| 115 | + && ln -s /sandbox/.openclaw-data/update-check.json /sandbox/.openclaw/update-check.json \ |
| 116 | + && chown -R sandbox:sandbox /sandbox/.openclaw /sandbox/.openclaw-data |
| 117 | + |
| 118 | +# Install OpenClaw CLI + PyYAML for inline Python scripts in e2e tests. |
| 119 | +# When bumping the openclaw version, rebuild this base image. |
| 120 | +RUN npm install -g [email protected] \ |
| 121 | + && pip3 install --no-cache-dir --break-system-packages "pyyaml==6.0.3" |
0 commit comments