feat(image): publish universal image flavor with toolchains + customize docs (#891)

This commit is contained in:
Carlos Florêncio
2026-05-13 20:45:29 +01:00
committed by GitHub
parent e3ea4e1766
commit 2544fd85f8
7 changed files with 604 additions and 5 deletions
+104 -1
View File
@@ -430,9 +430,112 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
docker-universal:
name: Build & push universal container image
needs: [prepare, docker]
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # push to GHCR
# Build flow: push to a per-run staging tag, gate on size against the
# staging tag, then `buildx imagetools create` to promote the same
# manifest to the user-facing tags. The promote step is metadata-only -
# no rebuild, no new bytes - so this costs us one extra registry call
# in exchange for never publishing an oversized image as :universal.
#
# Tradeoff: staging tags accumulate in GHCR over time (one per release
# run). Auto-cleanup isn't safe here - `imagetools create` produces a
# byte-identical manifest list when retagging a single source, so the
# staging tag and the promoted user-facing tags share the same package
# version in GHCR. Deleting the version to drop the staging tag would
# also drop :universal / :vX.Y.Z-universal. A separate cleanup workflow
# filtering for versions whose ONLY tags match `universal-staging-*`
# would be the correct way to address this if it becomes a problem.
env:
STAGING_IMAGE: ghcr.io/kdlbs/kandev:universal-staging-${{ needs.prepare.outputs.tag }}-${{ github.run_id }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.tag }}
- uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build universal on top of the vanilla image we just pushed. Passing
# the exact `:vX.Y.Z` tag (not `:latest`) keeps the pair coherent:
# universal-of-vX.Y.Z always rests on vanilla-vX.Y.Z, even if a later
# release moves `:latest`. The tag pushed here is the staging tag;
# final tags are applied below only if the size gate passes.
- name: Build and push (staging tag)
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.universal
push: true
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=ghcr.io/kdlbs/kandev:${{ needs.prepare.outputs.tag }}
tags: ${{ env.STAGING_IMAGE }}
cache-from: type=gha,scope=universal
cache-to: type=gha,mode=max,scope=universal
# Universal size gate. Inspects the staging tag - the image is in
# GHCR but under a per-run tag no user pulls. Failing the gate aborts
# before promotion, so the user-facing :universal / :vX.Y.Z-universal
# tags never move to an oversized image. Bump MAX_COMPRESSED_BYTES
# deliberately when adding scope, with a one-sentence justification
# in the commit msg.
- name: Enforce size budget
env:
MAX_COMPRESSED_BYTES: "2684354560" # 2.5 GiB
run: |
set -euo pipefail
# Inspect the multi-arch manifest and sum compressed layer sizes
# for linux/amd64. amd64 is the bigger of the two arches in
# practice, so gating on it gives us a single-number signal.
docker buildx imagetools inspect "$STAGING_IMAGE" --raw \
> /tmp/index.json
AMD64_DIGEST="$(jq -r '
.manifests[]
| select(.platform.architecture == "amd64" and .platform.os == "linux")
| .digest
' /tmp/index.json)"
docker buildx imagetools inspect "ghcr.io/kdlbs/kandev@${AMD64_DIGEST}" --raw \
> /tmp/manifest.json
TOTAL="$(jq '[.layers[].size] | add' /tmp/manifest.json)"
echo "Universal image (amd64) compressed size: $TOTAL bytes (max: $MAX_COMPRESSED_BYTES)"
if [ "$TOTAL" -gt "$MAX_COMPRESSED_BYTES" ]; then
echo "::error::Universal image exceeds compressed-size budget. Staging tag $STAGING_IMAGE will not be promoted. See docs/images.md inclusion policy." >&2
exit 1
fi
# Promote: `buildx imagetools create` retargets an existing manifest
# list to new tag(s) without rebuilding or re-uploading layers. Multi-
# arch is preserved. Only runs if the size gate passed (default step
# ordering); if any earlier step failed, the user-facing tags stay at
# whatever they pointed to before this run.
- name: Promote staging to final tags
run: |
set -euo pipefail
docker buildx imagetools create \
--tag "ghcr.io/kdlbs/kandev:${{ needs.prepare.outputs.version }}-universal" \
--tag "ghcr.io/kdlbs/kandev:${{ needs.prepare.outputs.tag }}-universal" \
--tag "ghcr.io/kdlbs/kandev:universal" \
"$STAGING_IMAGE"
publish-release:
name: Publish GitHub release
needs: [prepare, build-bundles]
# docker-universal is included so its size gate (and any build failure)
# blocks the release. Without this, publish-release runs in parallel with
# docker-universal and an oversized universal image still ships a release.
needs: [prepare, build-bundles, docker-universal]
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
permissions:
+115
View File
@@ -0,0 +1,115 @@
name: universal-rebuild
# Weekly rebuild of the universal image on top of the current :latest
# vanilla image, so apt security updates flow into universal even when
# kandev itself hasn't been re-released.
#
# - Pushes a moving `:universal-weekly-YYYYMMDD` tag plus refreshes
# `:universal` (the "latest universal" alias).
# - Does NOT push `:vX.Y.Z-universal`. Those are immutable per release;
# only the floating `:universal` and the dated weekly tags move here.
#
# Build flow mirrors release.yml's docker-universal: push to a per-run
# staging tag, gate on size against the staging tag, then promote the
# manifest to the user-facing tags via `buildx imagetools create`. The
# promote step is metadata-only - no rebuild, no extra layer upload - so
# a failed size gate aborts before `:universal` ever points at an
# oversized image (the previous week's tag remains live).
#
# Tradeoff: staging tags (one per weekly run) accumulate in GHCR. See the
# comment in release.yml's docker-universal job for why per-run cleanup
# isn't safe (shared manifest digest with promoted tags). A separate
# cleanup workflow filtering for `universal-staging-*` versions whose
# only tag matches is the right escape hatch if accumulation becomes a
# problem; ~52 stale tags/year is acceptable in the meantime.
#
# Manual trigger is also wired up so a maintainer can force a rebuild
# after a known CVE without waiting for the cron.
on:
schedule:
# Mondays 06:00 UTC. Picks up the previous week's Debian security
# patches without colliding with most weekday release work.
- cron: "0 6 * * 1"
workflow_dispatch: {}
permissions:
contents: read
jobs:
rebuild:
name: Rebuild universal on top of :latest
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
STAGING_IMAGE: ghcr.io/kdlbs/kandev:universal-staging-weekly-${{ github.run_id }}
steps:
- uses: actions/checkout@v4
- name: Compute date tag
id: date
run: echo "tag=$(date -u +%Y%m%d)" >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Rebuild against :latest deliberately - the whole point of the
# weekly is to pick up any base-image moves. Use --pull so the
# current :latest is freshly fetched, not whatever's in BuildKit's
# cache from a previous run.
- name: Build and push (staging tag)
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.universal
push: true
pull: true
platforms: linux/amd64,linux/arm64
build-args: |
BASE_IMAGE=ghcr.io/kdlbs/kandev:latest
tags: ${{ env.STAGING_IMAGE }}
cache-from: type=gha,scope=universal
cache-to: type=gha,mode=max,scope=universal
# Same size gate as release.yml's docker-universal job. A base-image
# update that adds significant weight (e.g. a new Debian dep pulled by
# apt security updates) is caught here before :universal is promoted.
# Keep MAX in sync with release.yml.
- name: Enforce size budget
env:
MAX_COMPRESSED_BYTES: "2684354560" # 2.5 GiB
run: |
set -euo pipefail
docker buildx imagetools inspect "$STAGING_IMAGE" --raw \
> /tmp/index.json
AMD64_DIGEST="$(jq -r '
.manifests[]
| select(.platform.architecture == "amd64" and .platform.os == "linux")
| .digest
' /tmp/index.json)"
docker buildx imagetools inspect "ghcr.io/kdlbs/kandev@${AMD64_DIGEST}" --raw \
> /tmp/manifest.json
TOTAL="$(jq '[.layers[].size] | add' /tmp/manifest.json)"
echo "Universal image (amd64) compressed size: $TOTAL bytes (max: $MAX_COMPRESSED_BYTES)"
if [ "$TOTAL" -gt "$MAX_COMPRESSED_BYTES" ]; then
echo "::error::Universal weekly rebuild exceeds compressed-size budget. Staging tag $STAGING_IMAGE will not be promoted; previous :universal remains live. See docs/images.md inclusion policy." >&2
exit 1
fi
# Promote: metadata-only retag from staging to the user-facing tags.
# If any earlier step fails, the previous :universal stays in place.
- name: Promote staging to final tags
run: |
set -euo pipefail
docker buildx imagetools create \
--tag "ghcr.io/kdlbs/kandev:universal" \
--tag "ghcr.io/kdlbs/kandev:universal-weekly-${{ steps.date.outputs.tag }}" \
"$STAGING_IMAGE"