77 lines
3 KiB
YAML
77 lines
3 KiB
YAML
name: probe-arm
|
|
on:
|
|
push:
|
|
branches: [ci/probe-arm]
|
|
jobs:
|
|
# The Alpine of the arm64 image, by digest: kaniko, which has no emulation here, takes the base of every stage for the
|
|
# platform of the runner, so the last stage is told which one to use.
|
|
base:
|
|
runs-on: docker
|
|
container:
|
|
image: gcr.io/go-containerregistry/crane:debug
|
|
outputs:
|
|
arm64: ${{ steps.digest.outputs.arm64 }}
|
|
steps:
|
|
- id: digest
|
|
run: echo "arm64=alpine@$(crane digest --platform linux/arm64 alpine:3.22)" >> "$GITHUB_OUTPUT"
|
|
|
|
# One image for each architecture. The Go program crosses to the other one with no emulation, and the last stage of the
|
|
# Dockerfile runs no command (see the Dockerfile).
|
|
image:
|
|
needs: [base]
|
|
runs-on: docker
|
|
strategy:
|
|
matrix:
|
|
arch: [amd64, arm64]
|
|
container:
|
|
image: gcr.io/kaniko-project/executor:v1.23.2-debug
|
|
steps:
|
|
- name: Build the image from the tag and push it as X.Y.Z-ARCH
|
|
env:
|
|
VERSION: probeD
|
|
ARCH: ${{ matrix.arch }}
|
|
ARM64_BASE: ${{ needs.base.outputs.arm64 }}
|
|
REGISTRY_USER: squid
|
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
run: |
|
|
set -eu
|
|
mkdir -p /kaniko/.docker
|
|
auth="$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" | base64 | tr -d '\n')"
|
|
printf '{"auths":{"git.kmalloc.org":{"auth":"%s"}}}' "$auth" > /kaniko/.docker/config.json
|
|
base=alpine:3.22
|
|
if [ "$ARCH" = arm64 ]; then base="$ARM64_BASE"; fi
|
|
/kaniko/executor \
|
|
--dockerfile Dockerfile \
|
|
--context "git://git.kmalloc.org/squid/sonda.git#refs/heads/ci/probe-arm" \
|
|
--build-arg "VERSION=${VERSION}" \
|
|
--build-arg "SONDA_ARCH=${ARCH}" \
|
|
--build-arg "RUNTIME_BASE=${base}" \
|
|
--label "org.opencontainers.image.version=${VERSION}" \
|
|
--destination "git.kmalloc.org/squid/sonda:${VERSION}-${ARCH}" \
|
|
--verbosity info
|
|
|
|
# The tags that people use (X.Y.Z, X.Y, latest) point at a list of the two images, so that each machine takes its own.
|
|
manifest:
|
|
needs: [image]
|
|
runs-on: docker
|
|
container:
|
|
image: gcr.io/go-containerregistry/crane:debug
|
|
steps:
|
|
- name: Join the images under X.Y.Z, X.Y and latest
|
|
env:
|
|
VERSION: probeD
|
|
REGISTRY_USER: squid
|
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
|
run: |
|
|
set -eu
|
|
image=git.kmalloc.org/squid/sonda
|
|
crane auth login git.kmalloc.org -u "$REGISTRY_USER" -p "$REGISTRY_TOKEN"
|
|
# Kaniko writes the architecture of the runner in both images: say the right one for each.
|
|
for arch in amd64 arm64; do
|
|
crane mutate "${image}:${VERSION}-${arch}" --set-platform "linux/${arch}" --tag "${image}:${VERSION}-${arch}"
|
|
done
|
|
crane index append \
|
|
--tag "${image}:${VERSION}" \
|
|
--manifest "${image}:${VERSION}-amd64" \
|
|
--manifest "${image}:${VERSION}-arm64"
|
|
crane tag "${image}:${VERSION}" probeD-latest
|