ci: push the published images with zstd -19 layers (#7159)

BuildKit compresses zstd at about level 11 at most, so the release and
nightly images now go through a composite action: the image is built
into an OCI layout, every layer is recompressed with the zstd CLI at
level 19, and a second build that only names the layout pushes it.
BuildKit keeps the recompressed layers and still attaches provenance
and the SBOM to the pushed digests.

On 2.4.0 this takes the native image from 94.6 to 70.1 MB on amd64 and
from 92.6 to 67.1 MB on arm64, and compat amd64 from 223.2 to 167.7 MB.
Pulling zstd layers needs Docker Engine 23.0 or later, so the
installation requirements move up from 20.10.

A new workflow tests the action on the pull requests that change it:
recompress.py against fixture layouts, then the whole action pushing a
two-platform image to a registry on the runner.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-10-31 21:38:13 -05:00
1 parent 00425b7824
commit e77823feed
10 files changed
+480 -27

No files matched your search

+4 -10
View File
@@ -216,14 +216,11 @@ jobs:
registry-type: public
- name: Build and push native nightly image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
uses: ./.github/actions/push-zstd-image
with:
context: .
source-date-epoch: ${{ steps.source_date.outputs.epoch }}
file: docker/Dockerfile.native-package
platforms: linux/amd64,linux/arm64
push: true
tags: |
floci/floci:nightly
floci/floci:nightly-${{ needs.prepare.outputs.version }}
@@ -242,14 +239,11 @@ jobs:
cache-to: type=gha,mode=max
- name: Build and push compat nightly image
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
uses: ./.github/actions/push-zstd-image
with:
context: .
source-date-epoch: ${{ steps.source_date.outputs.epoch }}
file: docker/Dockerfile.compat
platforms: linux/amd64,linux/arm64
push: true
tags: |
floci/floci:nightly-compat
floci/floci:nightly-${{ needs.prepare.outputs.version }}-compat
+87
View File
@@ -0,0 +1,87 @@
name: zstd image action
# Only release.yml and nightly.yml call .github/actions/push-zstd-image, so this checks it on the
# pull requests that change it: recompress.py against fixture layouts, then the whole action
# pushing a two-platform image to a registry on the runner.
on:
pull_request:
paths:
- '.github/actions/push-zstd-image/**'
- '.github/workflows/push-zstd-image.yml'
push:
branches:
- main
paths:
- '.github/actions/push-zstd-image/**'
- '.github/workflows/push-zstd-image.yml'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Cancel a superseded run only on pull requests; a run on main is left to finish (see ci.yml).
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
name: Test the zstd image action
runs-on: ubuntu-latest
timeout-minutes: 15
services:
registry:
image: registry:3@sha256:d4032d4cc323c1731c707931ecada07a53076eac38e3b61ae57533f170f2c6c3
ports:
- 5000:5000
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Test recompress.py
run: python3 .github/actions/push-zstd-image/test_recompress.py
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
with:
driver-opts: network=host
buildkitd-config-inline: |
[registry."localhost:5000"]
http = true
- name: Push a two-platform image through the action
id: push
uses: ./.github/actions/push-zstd-image
with:
file: .github/actions/push-zstd-image/test/Dockerfile
platforms: linux/amd64,linux/arm64
tags: localhost:5000/floci/zstd-test:ci
provenance: mode=max
sbom: true
- name: Check the pushed image
# Every layer must be zstd and every platform image must carry its attestations, and the
# runner's Docker must be able to pull and run the result.
env:
DIGEST: ${{ steps.push.outputs.digest }}
run: |
registry=http://localhost:5000/v2/floci/zstd-test
accept='Accept: application/vnd.oci.image.index.v1+json,application/vnd.oci.image.manifest.v1+json'
index=$(curl -fsS -H "$accept" "$registry/manifests/$DIGEST")
images=$(jq -r '.manifests[] | select(.platform.os == "linux") | .digest' <<<"$index")
if [ "$(wc -w <<<"$images")" -ne 2 ]; then
echo "::error::expected two platform images in $DIGEST, got: $images"
exit 1
fi
for image in $images; do
types=$(curl -fsS -H "$accept" "$registry/manifests/$image" | jq -r '[.layers[].mediaType] | unique | join(" ")')
if [ "$types" != application/vnd.oci.image.layer.v1.tar+zstd ]; then
echo "::error::$image has layers of type $types"
exit 1
fi
if ! jq -e --arg image "$image" 'any(.manifests[]; .annotations["vnd.docker.reference.digest"] == $image)' <<<"$index" > /dev/null; then
echo "::error::$image has no attestation manifest"
exit 1
fi
done
docker run --rm "localhost:5000/floci/zstd-test@$DIGEST" ls -l /usr/local/bin/healthcheck.sh
+6 -15
View File
@@ -437,14 +437,11 @@ jobs:
- name: Build and push native multi-arch image
id: native
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
uses: ./.github/actions/push-zstd-image
with:
context: .
source-date-epoch: ${{ steps.source_date.outputs.epoch }}
file: docker/Dockerfile.native-package
platforms: linux/amd64,linux/arm64
push: true
provenance: mode=max
sbom: true
tags: |
@@ -479,14 +476,11 @@ jobs:
- name: Build and push ARMv8.0 baseline image
id: baseline
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
uses: ./.github/actions/push-zstd-image
with:
context: .
source-date-epoch: ${{ steps.source_date.outputs.epoch }}
file: docker/Dockerfile.native-package
platforms: linux/arm64
push: true
provenance: mode=max
sbom: true
tags: |
@@ -508,14 +502,11 @@ jobs:
- name: Build and push compat multi-arch image
id: compat
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
env:
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
uses: ./.github/actions/push-zstd-image
with:
context: .
source-date-epoch: ${{ steps.source_date.outputs.epoch }}
file: docker/Dockerfile.compat
platforms: linux/amd64,linux/arm64
push: true
provenance: mode=max
sbom: true
tags: |