diff --git a/scripts/docker/install-sh-nonroot/Dockerfile b/scripts/docker/install-sh-nonroot/Dockerfile index 8e29715dbfb..f95859beedf 100644 --- a/scripts/docker/install-sh-nonroot/Dockerfile +++ b/scripts/docker/install-sh-nonroot/Dockerfile @@ -21,6 +21,15 @@ RUN --mount=type=cache,id=openclaw-install-sh-nonroot-apt-cache,target=/var/cach python3 \ sudo +# Preinstall the supported Node runtime in a cacheable build layer so the +# non-root smoke covers user-local npm prefixing and missing git without paying +# the full NodeSource bootstrap cost on every container run. +RUN --mount=type=cache,id=openclaw-install-sh-nonroot-apt-cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,id=openclaw-install-sh-nonroot-apt-lists,target=/var/lib/apt,sharing=locked \ + set -eux; \ + curl -fsSL https://deb.nodesource.com/setup_24.x | bash -; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends nodejs + RUN useradd -m -s /bin/bash app \ && echo "app ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/app diff --git a/scripts/docker/install-sh-nonroot/run.sh b/scripts/docker/install-sh-nonroot/run.sh index 787bfc8e809..6c026f34f64 100644 --- a/scripts/docker/install-sh-nonroot/run.sh +++ b/scripts/docker/install-sh-nonroot/run.sh @@ -15,6 +15,19 @@ if command -v git >/dev/null; then exit 1 fi +echo "==> Pre-flight: ensure supported Node is already present" +node -e ' + const version = process.versions.node.split(".").map(Number); + const ok = + version.length >= 2 && + (version[0] > 22 || (version[0] === 22 && version[1] >= 16)); + if (!ok) { + process.stderr.write(`unsupported node ${process.versions.node}\n`); + process.exit(1); + } +' +command -v npm >/dev/null + echo "==> Run installer (non-root user)" curl -fsSL "$INSTALL_URL" | bash