ci: probe two ways to build for arm64 (throw-away branch)
This commit is contained in:
parent
a2f8993601
commit
e21dca50da
2 changed files with 28 additions and 36 deletions
|
|
@ -3,54 +3,46 @@ on:
|
||||||
push:
|
push:
|
||||||
branches: [ci/probe-arm]
|
branches: [ci/probe-arm]
|
||||||
jobs:
|
jobs:
|
||||||
# One image for each architecture, each built by kaniko for its own: the Go program crosses to the other one with no
|
kaniko-explicit-platform:
|
||||||
# emulation, and the last stage of the Dockerfile runs no command (see the Dockerfile).
|
|
||||||
image:
|
|
||||||
runs-on: docker
|
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: Build the image from the tag and push it as X.Y.Z-ARCH
|
- name: arm64 with the build stages pinned to amd64
|
||||||
env:
|
env:
|
||||||
VERSION: probe
|
|
||||||
ARCH: ${{ matrix.arch }}
|
|
||||||
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' "$REGISTRY_USER" "$REGISTRY_TOKEN" | base64 | tr -d '\n')"
|
auth="$(printf '%s:%s' squid "$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 \
|
/kaniko/executor --custom-platform linux/arm64 --dockerfile Dockerfile \
|
||||||
--custom-platform "linux/${ARCH}" \
|
|
||||||
--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 "VERSION=${VERSION}" \
|
--build-arg TARGETOS=linux --build-arg TARGETARCH=arm64 --build-arg VERSION=probeA \
|
||||||
--label "org.opencontainers.image.version=${VERSION}" \
|
--destination git.kmalloc.org/squid/sonda:probeA-arm64 --verbosity info
|
||||||
--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.
|
buildah:
|
||||||
manifest:
|
|
||||||
needs: [image]
|
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
|
||||||
image: gcr.io/go-containerregistry/crane:debug
|
|
||||||
steps:
|
steps:
|
||||||
- name: Join the images under X.Y.Z, X.Y and latest
|
- name: Can buildah assemble an arm64 image here, with no daemon and no emulation?
|
||||||
env:
|
env:
|
||||||
VERSION: probe
|
|
||||||
REGISTRY_USER: squid
|
|
||||||
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
image=git.kmalloc.org/squid/sonda
|
apt-get update -qq >/dev/null && apt-get install -y -qq buildah >/dev/null 2>&1
|
||||||
crane auth login git.kmalloc.org -u "$REGISTRY_USER" -p "$REGISTRY_TOKEN"
|
buildah --version
|
||||||
crane index append \
|
export STORAGE_DRIVER=vfs BUILDAH_ISOLATION=chroot
|
||||||
--tag "${image}:${VERSION}" \
|
mkdir -p /tmp/ctx/data && printf '#!/bin/sh\necho hello\n' > /tmp/ctx/hello && chmod +x /tmp/ctx/hello
|
||||||
--manifest "${image}:${VERSION}-amd64" \
|
for arch in amd64 arm64; do
|
||||||
--manifest "${image}:${VERSION}-arm64"
|
c=$(buildah from --arch "$arch" --os linux docker.io/library/alpine:3.22)
|
||||||
crane tag "${image}:${VERSION}" probe-latest
|
buildah copy "$c" /tmp/ctx/hello /usr/local/bin/hello
|
||||||
|
buildah copy --chown 10001:10001 "$c" /tmp/ctx/data /data
|
||||||
|
buildah config --user 10001:10001 --workingdir /data --entrypoint '["hello"]' "$c"
|
||||||
|
buildah commit "$c" "localhost/probe:$arch"
|
||||||
|
done
|
||||||
|
buildah login -u squid -p "$REGISTRY_TOKEN" git.kmalloc.org
|
||||||
|
buildah manifest create probeB
|
||||||
|
buildah manifest add probeB localhost/probe:amd64
|
||||||
|
buildah manifest add probeB localhost/probe:arm64
|
||||||
|
buildah manifest push --all probeB docker://git.kmalloc.org/squid/sonda:probeB
|
||||||
|
echo done
|
||||||
|
|
|
||||||
|
|
@ -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 --platform=$BUILDPLATFORM node:24-alpine AS web
|
FROM --platform=linux/amd64 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,7 +12,7 @@ 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 --platform=$BUILDPLATFORM golang:1.27-alpine AS build
|
FROM --platform=linux/amd64 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
|
||||||
|
|
@ -30,7 +30,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build -
|
||||||
|
|
||||||
# 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 --platform=$BUILDPLATFORM alpine:3.22 AS rootfs
|
FROM --platform=linux/amd64 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 \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue