ci: probe the real two-architecture jobs (throw-away branch)
All checks were successful
probe-arm / base (push) Successful in 9s
probe-arm / image (arm64) (push) Successful in 3m17s
probe-arm / image (amd64) (push) Successful in 3m20s
probe-arm / manifest (push) Successful in 2s

This commit is contained in:
tgiachi 2026-11-16 14:27:08 +01:00
commit 339f2bfb95
2 changed files with 66 additions and 10 deletions

View file

@ -3,21 +3,75 @@ on:
push: push:
branches: [ci/probe-arm] branches: [ci/probe-arm]
jobs: jobs:
base-by-digest: # 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 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: container:
image: gcr.io/kaniko-project/executor:v1.23.2-debug image: gcr.io/kaniko-project/executor:v1.23.2-debug
steps: steps:
- name: kaniko for the runner's own platform, arm64 program, arm64 base by digest - name: Build the image from the tag and push it as X.Y.Z-ARCH
env: env:
VERSION: probeD
ARCH: ${{ matrix.arch }}
ARM64_BASE: ${{ needs.base.outputs.arm64 }}
REGISTRY_USER: squid
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }} REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: | run: |
set -eu set -eu
mkdir -p /kaniko/.docker mkdir -p /kaniko/.docker
auth="$(printf '%s:%s' squid "$REGISTRY_TOKEN" | base64 | tr -d '\n')" auth="$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" | base64 | tr -d '\n')"
printf '{"auths":{"git.kmalloc.org":{"auth":"%s"}}}' "$auth" > /kaniko/.docker/config.json printf '{"auths":{"git.kmalloc.org":{"auth":"%s"}}}' "$auth" > /kaniko/.docker/config.json
/kaniko/executor --dockerfile Dockerfile \ 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" \ --context "git://git.kmalloc.org/squid/sonda.git#refs/heads/ci/probe-arm" \
--build-arg SONDA_ARCH=arm64 --build-arg VERSION=probeC \ --build-arg "VERSION=${VERSION}" \
--build-arg RUNTIME_BASE=alpine@sha256:e233f2058b0628266762f745a2c17e623b418e0090f47d223909d1f9a7d4367e \ --build-arg "SONDA_ARCH=${ARCH}" \
--destination git.kmalloc.org/squid/sonda:probeC-arm64 --verbosity info --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

View file

@ -2,7 +2,7 @@
# The web app: built once here, written (by its Vite config) to /src/internal/webui/dist, where the Go # The web app: built once here, written (by its Vite config) to /src/internal/webui/dist, where the Go
# build below embeds it. Nothing of Node reaches the final image. # build below embeds it. Nothing of Node reaches the final image.
FROM node:24-alpine AS web FROM --platform=$BUILDPLATFORM node:24-alpine AS web
WORKDIR /src/web WORKDIR /src/web
COPY web/package.json web/package-lock.json ./ COPY web/package.json web/package-lock.json ./
RUN npm ci RUN npm ci
@ -12,11 +12,12 @@ RUN npm run build
# Build: Sonda has no CGO (SQLite, PostgreSQL and the tag reader are pure Go), so the binary # Build: Sonda has no CGO (SQLite, PostgreSQL and the tag reader are pure Go), so the binary
# is static and the final image needs nothing but it and the CA certificates. The web app is inside it # is static and the final image needs nothing but it and the CA certificates. The web app is inside it
# (-tags webui), so sondad serves it on / and the API on /api. # (-tags webui), so sondad serves it on / and the API on /api.
FROM golang:1.27-alpine AS build FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS build
# Built on the machine that builds, for the machine that runs: Go crosses to another architecture with no emulation # Built on the machine that builds, for the machine that runs: Go crosses to another architecture with no emulation
# (TARGETOS and TARGETARCH come from the platform asked for). # (TARGETOS and TARGETARCH come from the platform asked for).
ARG TARGETOS ARG TARGETOS
ARG TARGETARCH ARG TARGETARCH
# SONDA_ARCH is for a builder that cannot say TARGETARCH (the CI release, see .forgejo/workflows/release.yml).
ARG SONDA_ARCH ARG SONDA_ARCH
WORKDIR /src WORKDIR /src
COPY go.mod go.sum ./ COPY go.mod go.sum ./
@ -31,12 +32,13 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${SONDA_ARCH:-${TARGETARCH:-amd
# What the image has besides the program (the zones of tzdata, the user, the folders) is made here, on the machine that # What the image has besides the program (the zones of tzdata, the user, the folders) is made here, on the machine that
# builds. The last stage then runs no command, so it can be built for another architecture with no emulation. # builds. The last stage then runs no command, so it can be built for another architecture with no emulation.
FROM alpine:3.22 AS rootfs FROM --platform=$BUILDPLATFORM alpine:3.22 AS rootfs
RUN apk add --no-cache tzdata \ RUN apk add --no-cache tzdata \
&& addgroup -S -g 10001 sonda \ && addgroup -S -g 10001 sonda \
&& adduser -S -u 10001 -G sonda -h /data -H sonda \ && adduser -S -u 10001 -G sonda -h /data -H sonda \
&& mkdir -p /out/data /out/music && mkdir -p /out/data /out/music
# RUNTIME_BASE is alpine:3.22 unless the CI release asks for another architecture, with the digest of that one.
ARG RUNTIME_BASE=alpine:3.22 ARG RUNTIME_BASE=alpine:3.22
FROM ${RUNTIME_BASE} FROM ${RUNTIME_BASE}
LABEL org.opencontainers.image.title="Sonda" \ LABEL org.opencontainers.image.title="Sonda" \