CI: cache Docker builds in workflows

This commit is contained in:
Vincent Koc
2026-03-08 17:10:37 -07:00
parent 5fab5c6284
commit 291b3398fd
2 changed files with 27 additions and 9 deletions

View File

@@ -109,6 +109,8 @@ jobs:
labels: ${{ steps.labels.outputs.value }}
provenance: false
push: true
cache-from: type=gha,scope=docker-release-amd64
cache-to: type=gha,mode=max,scope=docker-release-amd64
- name: Build and push amd64 slim image
id: build-slim
@@ -122,6 +124,8 @@ jobs:
labels: ${{ steps.labels.outputs.value }}
provenance: false
push: true
cache-from: type=gha,scope=docker-release-amd64
cache-to: type=gha,mode=max,scope=docker-release-amd64
# Build arm64 images (default + slim share the build stage cache)
build-arm64:
@@ -210,6 +214,8 @@ jobs:
labels: ${{ steps.labels.outputs.value }}
provenance: false
push: true
cache-from: type=gha,scope=docker-release-arm64
cache-to: type=gha,mode=max,scope=docker-release-arm64
- name: Build and push arm64 slim image
id: build-slim
@@ -223,6 +229,8 @@ jobs:
labels: ${{ steps.labels.outputs.value }}
provenance: false
push: true
cache-from: type=gha,scope=docker-release-arm64
cache-to: type=gha,mode=max,scope=docker-release-arm64
# Create multi-platform manifests
create-manifest:

View File

@@ -34,7 +34,12 @@ jobs:
run: |
set -euo pipefail
docker build -t openclaw-sandbox-smoke-base:bookworm-slim - <<'EOF'
docker buildx build \
--load \
--tag openclaw-sandbox-smoke-base:bookworm-slim \
--cache-from type=gha,scope=sandbox-common-smoke-base \
--cache-to type=gha,mode=max,scope=sandbox-common-smoke-base \
- <<'EOF'
FROM debian:bookworm-slim
RUN useradd --create-home --shell /bin/bash sandbox
USER sandbox
@@ -46,14 +51,19 @@ jobs:
run: |
set -euo pipefail
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 \
scripts/sandbox-common-setup.sh
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 \
.
u="$(docker run --rm openclaw-sandbox-common-smoke:bookworm-slim sh -lc 'id -un')"
test "$u" = "sandbox"