在 VM Runner 中构建发布镜像 #17

Merged
panxiao81 merged 1 commits from refactor/publish-on-vm into main 2026-09-16 18:29:27 +00:00
Showing only changes of commit 3e69d102dd - Show all commits
+2 -34
View File
@@ -17,7 +17,7 @@ on:
jobs: jobs:
publish-images: publish-images:
name: publish-images name: publish-images
runs-on: [self-hosted, pod] runs-on: [self-hosted, vm]
timeout-minutes: 45 timeout-minutes: 45
permissions: permissions:
contents: read contents: read
@@ -41,29 +41,6 @@ jobs:
apt-get install --yes --no-install-recommends shellcheck apt-get install --yes --no-install-recommends shellcheck
shellcheck scripts/* shellcheck scripts/*
- name: Start Docker
shell: bash
run: |
set -euo pipefail
# The runner Pod itself uses an overlay filesystem. A nested overlay
# snapshotter cannot mount there, so use the copy-based vfs driver.
dockerd \
--storage-driver=vfs \
--feature containerd-snapshotter=false \
>/tmp/dockerd.log 2>&1 &
for _ in $(seq 1 60); do
if docker info >/dev/null 2>&1; then
exit 0
fi
if ! kill -0 "$!" 2>/dev/null; then
cat /tmp/dockerd.log >&2
exit 1
fi
sleep 1
done
cat /tmp/dockerd.log >&2
exit 1
- name: Build and publish - name: Build and publish
shell: bash shell: bash
run: | run: |
@@ -74,10 +51,9 @@ jobs:
image_tag="sha-${GITHUB_SHA}" image_tag="sha-${GITHUB_SHA}"
docker_config=$(mktemp -d) docker_config=$(mktemp -d)
jwt_file=$(mktemp) jwt_file=$(mktemp)
buildkit_config=$(mktemp)
cleanup() { cleanup() {
docker buildx rm ci-builder >/dev/null 2>&1 || true docker buildx rm ci-builder >/dev/null 2>&1 || true
rm -rf -- "$docker_config" "$jwt_file" "$buildkit_config" rm -rf -- "$docker_config" "$jwt_file"
} }
trap cleanup EXIT trap cleanup EXIT
export DOCKER_CONFIG="$docker_config" export DOCKER_CONFIG="$docker_config"
@@ -90,17 +66,9 @@ jobs:
jq -er '.[0].svids[0].svid' "$jwt_file" | \ jq -er '.[0].svids[0].svid' "$jwt_file" | \
docker login "$PUSH_REGISTRY" --username zot --password-stdin docker login "$PUSH_REGISTRY" --username zot --password-stdin
# The docker driver cannot publish attestations. Use an isolated
# BuildKit worker, but force its snapshotter to copy-based native so
# it does not attempt nested overlay mounts inside the runner Pod.
printf '%s\n' \
'[worker.oci]' \
' snapshotter = "native"' \
>"$buildkit_config"
docker buildx create \ docker buildx create \
--name ci-builder \ --name ci-builder \
--driver docker-container \ --driver docker-container \
--buildkitd-config "$buildkit_config" \
--use --use
publish() { publish() {