From f99f346eef31f776de6341061cf24a3db8f335fb Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 8 Mar 2026 17:51:17 -0700 Subject: [PATCH] CI: route sandbox smoke through setup script --- .github/workflows/sandbox-common-smoke.yml | 24 ++++++++++------------ scripts/sandbox-common-setup.sh | 16 ++++++++++++++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/sandbox-common-smoke.yml b/.github/workflows/sandbox-common-smoke.yml index 0102479cb7d..0e954e07af0 100644 --- a/.github/workflows/sandbox-common-smoke.yml +++ b/.github/workflows/sandbox-common-smoke.yml @@ -51,19 +51,17 @@ jobs: run: | set -euo pipefail - docker buildx build \ - --load \ - --tag openclaw-sandbox-common-smoke:bookworm-slim \ - --file Dockerfile.sandbox-common \ - --build-arg BASE_IMAGE=openclaw-sandbox-smoke-base:bookworm-slim \ - --build-arg PACKAGES=ca-certificates \ - --build-arg INSTALL_PNPM=0 \ - --build-arg INSTALL_BUN=0 \ - --build-arg INSTALL_BREW=0 \ - --build-arg FINAL_USER=sandbox \ - --cache-from type=gha,scope=sandbox-common-smoke \ - --cache-to type=gha,mode=max,scope=sandbox-common-smoke \ - . + BASE_IMAGE="openclaw-sandbox-smoke-base:bookworm-slim" \ + TARGET_IMAGE="openclaw-sandbox-common-smoke:bookworm-slim" \ + PACKAGES="ca-certificates" \ + INSTALL_PNPM=0 \ + INSTALL_BUN=0 \ + INSTALL_BREW=0 \ + FINAL_USER=sandbox \ + OPENCLAW_DOCKER_BUILD_USE_BUILDX=1 \ + OPENCLAW_DOCKER_BUILD_CACHE_FROM="type=gha,scope=sandbox-common-smoke" \ + OPENCLAW_DOCKER_BUILD_CACHE_TO="type=gha,mode=max,scope=sandbox-common-smoke" \ + scripts/sandbox-common-setup.sh u="$(docker run --rm openclaw-sandbox-common-smoke:bookworm-slim sh -lc 'id -un')" test "$u" = "sandbox" diff --git a/scripts/sandbox-common-setup.sh b/scripts/sandbox-common-setup.sh index 95c90c8cb97..258ed19bcae 100755 --- a/scripts/sandbox-common-setup.sh +++ b/scripts/sandbox-common-setup.sh @@ -10,6 +10,9 @@ BUN_INSTALL_DIR="${BUN_INSTALL_DIR:-/opt/bun}" INSTALL_BREW="${INSTALL_BREW:-1}" BREW_INSTALL_DIR="${BREW_INSTALL_DIR:-/home/linuxbrew/.linuxbrew}" FINAL_USER="${FINAL_USER:-sandbox}" +OPENCLAW_DOCKER_BUILD_USE_BUILDX="${OPENCLAW_DOCKER_BUILD_USE_BUILDX:-0}" +OPENCLAW_DOCKER_BUILD_CACHE_FROM="${OPENCLAW_DOCKER_BUILD_CACHE_FROM:-}" +OPENCLAW_DOCKER_BUILD_CACHE_TO="${OPENCLAW_DOCKER_BUILD_CACHE_TO:-}" if ! docker image inspect "${BASE_IMAGE}" >/dev/null 2>&1; then echo "Base image missing: ${BASE_IMAGE}" @@ -19,7 +22,18 @@ fi echo "Building ${TARGET_IMAGE} with: ${PACKAGES}" -docker build \ +build_cmd=(docker build) +if [ "${OPENCLAW_DOCKER_BUILD_USE_BUILDX}" = "1" ]; then + build_cmd=(docker buildx build --load) + if [ -n "${OPENCLAW_DOCKER_BUILD_CACHE_FROM}" ]; then + build_cmd+=(--cache-from "${OPENCLAW_DOCKER_BUILD_CACHE_FROM}") + fi + if [ -n "${OPENCLAW_DOCKER_BUILD_CACHE_TO}" ]; then + build_cmd+=(--cache-to "${OPENCLAW_DOCKER_BUILD_CACHE_TO}") + fi +fi + +"${build_cmd[@]}" \ -t "${TARGET_IMAGE}" \ -f Dockerfile.sandbox-common \ --build-arg BASE_IMAGE="${BASE_IMAGE}" \