Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 123 additions & 16 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ name: Build and publish images
# Shared build definition for both publish triggers (edge on push-to-main,
# release on v* tags — see edge.yml / release.yml). A reusable workflow
# (workflow_call), not a composite action, because:
# - it needs two independent jobs (backend, frontend) with different
# toolchains and runtimes, each with its own `permissions:`; a composite
# action is a single flat step sequence and cannot declare permissions or
# split into parallel jobs.
# - it needs independent jobs (backend per architecture, the backend
# manifest list, frontend) with different toolchains, runners and
# runtimes, each with its own `permissions:`; a composite action is a
# single flat step sequence and cannot declare permissions or split into
# parallel jobs.
# - callers select identity kind and docker/metadata-action tag rules
# (edge vs semver), so the two call sites cannot drift apart on the
# actual build/push mechanics.
#
# Both images are published for linux/amd64 and linux/arm64 as one manifest
# list per tag (docs/adr/0043). A tag moves only when both architectures are
# built: the backend tags are written by one job that needs every
# per-architecture build, the frontend tags by one multi-platform push.
on:
workflow_call:
inputs:
Expand Down Expand Up @@ -66,14 +72,14 @@ jobs:
# the ELF interpreter/RUNPATH because a Nix-built binary points at
# /nix/store paths that don't exist in the UBI9 micro runtime.
#
# GitHub Actions does not build in the Nix devshell (pr.yml's native job
# GitHub Actions does not build in the Nix devshell (pr.yml's native jobs
# uses graalvm/setup-graalvm@v1, matching the toolchain split documented
# there), so the Nix-path problem this Dockerfile's patcher stage exists
# for does not apply here — the patchelf step is a harmless no-op against a
# standard-interpreter binary (it resets the interpreter to the same
# standard glibc loader path and drops an RPATH that isn't set). We still
# reuse this Dockerfile unmodified rather than Dockerfile.native /
# .native-micro because:
# reuse this Dockerfile rather than Dockerfile.native / .native-micro
# because:
# - it is the only one of the four docker/ files that has been touched
# since the default Quarkus scaffold (Mar 1) — the other three are
# untouched generated stubs — i.e. it is the file this project actually
Expand All @@ -91,23 +97,43 @@ jobs:
# glibc coupling: native-image links against the *build host's* system
# glibc, because this job does not use `quarkus.native.container-build`.
# The runtime base is UBI9 (glibc 2.34). This has held on every published
# image so far, but a future `ubuntu-latest` bump can make the binary fail
# to start ("GLIBC_x.xx not found"). If that happens, switch to
# image so far, but a runner image bump can make the binary fail to start
# ("GLIBC_x.xx not found"). The runner images are therefore pinned, to the
# same Ubuntu release on both architectures and to the same pair that
# pr.yml's native jobs gate on. If a bump breaks the coupling, switch to
# `quarkus.native.container-build=true` with a pinned builder image.
# PR native ITs exercise their own build of the shipped image recipe; this
# publishing run separately recompiles the event's source with its resolved
# identity, then packages that binary without recompilation.
#
# One job per architecture: native-image has no cross-compilation, so each
# binary is compiled on a runner of its own architecture (emulation was
# rejected, docs/adr/0043). Each job pushes its image by digest only (no
# tag); `backend-manifest` below writes the tags.
backend:
name: backend image
name: backend image (${{ matrix.arch }})
needs: identity
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
env:
IMAGE: ghcr.io/sreyardship/platformup2date/backend
BUILD_VERSION: ${{ needs.identity.outputs.version }}
BUILD_SOURCE_SHA: ${{ needs.identity.outputs.source-sha }}
runs-on: ubuntu-latest
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
permissions:
contents: read
packages: write
# A matrix job has one set of outputs, so each architecture writes its own
# key and leaves the other empty.
outputs:
digest-amd64: ${{ steps.digest.outputs.digest-amd64 }}
digest-arm64: ${{ steps.digest.outputs.digest-arm64 }}
steps:
- name: Check out resolved source
uses: actions/checkout@v7
Expand All @@ -117,7 +143,7 @@ jobs:
- name: Verify build source
run: test "$(git rev-parse HEAD)" = "$BUILD_SOURCE_SHA"

# Same split as pr.yml's native job: GraalVM CE 25 provides
# Same split as pr.yml's native jobs: GraalVM CE 25 provides
# native-image (via GRAALVM_HOME, which Quarkus prefers over
# JAVA_HOME); Gradle 8.14.x cannot launch on JDK 25, so JDK 21 is set
# up afterwards and wins JAVA_HOME/PATH for the Gradle launcher.
Expand Down Expand Up @@ -169,22 +195,97 @@ jobs:
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/sreyardship/platformup2date/backend
images: ${{ env.IMAGE }}
tags: ${{ inputs.tags-config }}
labels: |
org.opencontainers.image.licenses=Apache-2.0

- name: Build and push backend image
# Tags are not applied here; only the labels of the metadata are used.
- name: Build and push backend image by digest
id: build
uses: docker/build-push-action@v7
with:
context: backend
file: backend/src/main/docker/Dockerfile.native-ci
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/${{ matrix.arch }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export image digest
id: digest
env:
ARCH: ${{ matrix.arch }}
DIGEST: ${{ steps.build.outputs.digest }}
run: |
set -euo pipefail
[[ "$DIGEST" == sha256:* ]] || { echo "no image digest for $ARCH" >&2; exit 1; }
echo "digest-$ARCH=$DIGEST" >> "$GITHUB_OUTPUT"

# Writes every backend tag as one manifest list over the two
# per-architecture images. `needs: backend` covers the whole matrix, so no
# tag is written or moved when one architecture fails.
backend-manifest:
name: backend image (manifest list)
needs: [identity, backend]
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
packages: write
env:
IMAGE: ghcr.io/sreyardship/platformup2date/backend
steps:
- name: Check out resolved source
uses: actions/checkout@v7
with:
ref: ${{ needs.identity.outputs.source-sha }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute image metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE }}
tags: ${{ inputs.tags-config }}

- name: Create and push manifest list
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST_AMD64: ${{ needs.backend.outputs.digest-amd64 }}
DIGEST_ARM64: ${{ needs.backend.outputs.digest-arm64 }}
run: |
set -euo pipefail
sources=()
for digest in "$DIGEST_AMD64" "$DIGEST_ARM64"; do
[[ "$digest" == sha256:* ]] || { echo 'a per-architecture digest is missing' >&2; exit 1; }
sources+=("$IMAGE@$digest")
done
tag_args=()
while IFS= read -r tag; do
if [[ -n "$tag" ]]; then tag_args+=(--tag "$tag"); fi
done <<< "$TAGS"
(( ${#tag_args[@]} > 0 )) || { echo 'no tags resolved' >&2; exit 1; }
docker buildx imagetools create "${tag_args[@]}" "${sources[@]}"

- name: Verify published platforms
env:
TAGS: ${{ steps.meta.outputs.tags }}
run: xargs bash ci/check-image-platforms.sh linux/amd64,linux/arm64 <<< "$TAGS"

# Frontend: build identity is embedded in the static assets. Deployment
# config (API_BASE_URL/OIDC) remains injected separately at container start.
# The assets are the same for every architecture and the Dockerfile has no
# target-platform RUN step, so one job builds both platforms without
# emulation and pushes them as one manifest list.
frontend:
name: frontend image
needs: identity
Expand Down Expand Up @@ -231,6 +332,12 @@ jobs:
build-args: |
BUILD_VERSION=${{ needs.identity.outputs.version }}
BUILD_VERSION_REQUIRED=true
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Verify published platforms
env:
TAGS: ${{ steps.meta.outputs.tags }}
run: xargs bash ci/check-image-platforms.sh linux/amd64,linux/arm64 <<< "$TAGS"
23 changes: 21 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: Build identity CLI tests
run: bash ci/test-resolve-build-version.sh

- name: Native Dockerfile loader per target architecture (patcher stage only)
run: bash ci/test-native-dockerfile-arch.sh

- name: Backend unit + integration tests
run: gradle --no-daemon :backend:test

Expand Down Expand Up @@ -71,9 +74,25 @@ jobs:
# (SshOsReleaseResourceIT et al. — see docs/adr/0025). `quarkusIntTest` boots
# the freshly built native binary and exercises it over HTTP, so this job
# gates on native-image regressions the JVM-mode `fast` job cannot see.
#
# One job per published architecture (docs/adr/0043). The publish workflows
# run only on main and on tags, so these jobs are the only pre-merge proof
# that each architecture's binary compiles and that its shipped image boots
# on the UBI9 runtime. The runner images are pinned to the same pair that
# build-images.yml compiles the published binaries on (glibc coupling, see
# the comment there). fail-fast is off so that one architecture's failure
# does not hide the other's result.
native:
name: native
runs-on: ubuntu-latest
name: native (${{ matrix.arch }})
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
steps:
- name: Check out repository
Expand Down
17 changes: 10 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,22 @@ yarn build # production build

## The merge gate

Every pull request must pass three required checks before it can merge:
Every pull request must pass four required checks before it can merge:

- **`fast`** runs the backend unit and JVM integration tests
(`gradle :backend:test`) plus the frontend test suite.
- **`native`** performs a full GraalVM native build and runs the native
integration tests against the built image. Expect roughly 20–30 minutes.
Native-image behavior can diverge from JVM behavior in ways the fast job
cannot see; `docs/adr/0025-ssh-os-release-native-image-reachability.md`
records one example.
- **`native (amd64)`** and **`native (arm64)`** each perform a full GraalVM
native build on a runner of that architecture and run the native
integration tests against the built image. The two jobs run in parallel;
expect roughly 20–30 minutes. Native-image behavior can diverge from JVM
behavior in ways the fast job cannot see;
`docs/adr/0025-ssh-os-release-native-image-reachability.md` records one
example. Both architectures are published, so both are gated
(`docs/adr/0043-images-are-multi-arch-built-natively-per-architecture.md`).
- **`manifests`** builds every shipped Kubernetes composition and validates
the rendered resources with kubeconform.

All three jobs are defined in `.github/workflows/pr.yml`.
All four jobs are defined in `.github/workflows/pr.yml`.

## Conventions

Expand Down
17 changes: 13 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ under `.github/workflows/` and in
## Channels

Both images (`ghcr.io/sreyardship/platformup2date/backend` and
`.../frontend`) are always tagged in lockstep. What you can pull:
`.../frontend`) are always tagged in lockstep. Each tag is one manifest list
for `linux/amd64` and `linux/arm64`, so the same tag works on both
architectures. What you can pull:

| Tag | Moves when | Meant for |
|---|---|---|
Expand All @@ -21,6 +23,11 @@ Release-candidate tags (`vX.Y.Z-rc.N`) publish **only** their exact
`X.Y.Z-rc.N` image tag and a GitHub prerelease — they never move `latest`,
`X.Y`, `X`, or the deploy pins.

On every channel, the backend native binary is compiled on one runner per
architecture; a last job joins the two images into the manifest list and
writes the tags. A tag moves only when both architectures are built
([ADR 0043](docs/adr/0043-images-are-multi-arch-built-natively-per-architecture.md)).

There is deliberately **no release per merge**: merges to `main` feed `edge`,
and a release happens only when a maintainer tags. `edge` plus the immutable
`sha-<short>` tags are the pre-release proving ground, so no separate rc
Expand Down Expand Up @@ -84,8 +91,9 @@ does not ask the backend for its version.

The shared publishing workflow resolves identity once **after checkout**, using
[`ci/resolve-build-version.sh`](ci/resolve-build-version.sh). Release tags must
be strict SemVer with a leading `v`; only that prefix is removed. Both image
jobs check out the resolved commit and consume the same identity:
be strict SemVer with a leading `v`; only that prefix is removed. Every image
job (the backend job of each architecture and the frontend job) checks out the
resolved commit and consumes the same identity:

- Backend: `gradle ... -PbuildVersion=<identity> -PbuildVersionRequired=true`, before
native compilation, not in the later Docker packaging step.
Expand All @@ -110,7 +118,8 @@ docker build frontend --build-arg BUILD_VERSION=1.2.3-rc.6+build.1 \
PR checks test the identity CLI, rebuild the JVM artifact with changed injection
without cleaning generated output, query its public endpoint, and exercise the
frontend build and nginx images. Native integration tests use explicit
injection through the packaged native image. Those tests validate the source
injection through the packaged native image, on both published architectures.
Those tests validate the source
and image recipe, **not the exact binary later published**: the publishing run
separately recompiles the triggering source with the release/edge identity.
Tag pushes rebuild both images; they do not promote or retag an earlier `edge`
Expand Down
17 changes: 14 additions & 3 deletions backend/src/main/docker/Dockerfile.native-ci
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@
# so the loader resolves libc/libpthread/librt/libdl from the micro image's
# /lib64. The binary requires GLIBC_2.34, so the runtime base must be UBI9
# (glibc 2.34) — quarkus-micro-image:2.0 is UBI8 (glibc 2.28) and is too old.
FROM alpine:3 AS patcher
#
# The loader path depends on the target architecture (docs/adr/0043). patchelf
# only rewrites ELF headers, so this stage runs on the build platform and
# never needs emulation; the binary itself must already be compiled for the
# target. BUILDPLATFORM/TARGETARCH are BuildKit's automatic platform args.
FROM --platform=$BUILDPLATFORM alpine:3 AS patcher
ARG TARGETARCH
RUN apk add --no-cache patchelf
WORKDIR /work/
COPY build-native/*-runner /work/application
RUN patchelf \
--set-interpreter /lib64/ld-linux-x86-64.so.2 \
RUN case "$TARGETARCH" in \
amd64) loader=/lib64/ld-linux-x86-64.so.2 ;; \
arm64) loader=/lib/ld-linux-aarch64.so.1 ;; \
*) echo "unsupported target architecture: ${TARGETARCH:-unset (BuildKit required)}; supported: amd64, arm64" >&2; exit 1 ;; \
esac \
&& patchelf \
--set-interpreter "$loader" \
--remove-rpath \
/work/application

Expand Down
19 changes: 15 additions & 4 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GitHub Actions build identity checks
# GitHub Actions build identity and image checks

These are local/CI helper scripts, not the retired Tekton pipelines (ADR-0023).
Run from the repository root:
Expand All @@ -7,6 +7,8 @@ Run from the repository root:
bash ci/test-resolve-build-version.sh
bash ci/check-backend-build-version.sh
bash frontend/ci/bin/test-build-version-image.sh
bash ci/test-native-dockerfile-arch.sh
bash ci/check-image-platforms.sh linux/amd64,linux/arm64 <image-ref>...
```

- `resolve-build-version.sh release v<semver>` validates strict SemVer and
Expand All @@ -22,9 +24,18 @@ bash frontend/ci/bin/test-build-version-image.sh
unreachable. Runtime identity overrides must be ignored.
- The frontend check requires Docker, curl, and Node; it checks the static
artifact through both shipped nginx configurations. It never publishes images.
- The native Dockerfile test requires Docker (BuildKit) and `readelf`. It builds
only the `patcher` stage of `Dockerfile.native-ci` with a fixture binary: each
supported target platform gets its ELF loader, `/nix/store` paths are removed,
and an unsupported platform fails the build. It needs no native build and no
emulation.
- `check-image-platforms.sh` reads each given published tag from the registry
and fails unless its manifest list carries every given platform. The publish
workflow runs it on each tag it writes (ADR-0043).

Publishing resolves once in `build-images.yml`'s upstream identity job. Both
build jobs check out that job's resolved source commit and consume its version
output, with required-injection flags enabled. PRs exercise the same injection
Publishing resolves once in `build-images.yml`'s upstream identity job. Every
build job (the backend job of each architecture and the frontend job) checks
out that job's resolved source commit and consumes its version output, with
required-injection flags enabled. PRs exercise the same injection
contracts without GHCR login or write permissions. Native PR integration tests
use `1.2.3-rc.6+ci.1`; their assertions belong to the backend integration suite.
Loading
Loading