From e3a9b019c08b07f81612bf408eaf7c017e8fc59f Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Fri, 20 Nov 2026 22:24:05 +1100 Subject: [PATCH] ci: push UI then API, move latest last; OCI source label; pin nginx base by digest - Build UI dist and push the UI image before the API image, and tag latest on both only after both versioned tags exist. - Label both images org.opencontainers.image.source so ghcr links the packages to the repo. - Pin nginx:alpine by digest in scripts/ui-image.sh and ui/Dockerfile.ui. - Release trigger narrowed to v[0-9]* tags. --- .github/workflows/release.yml | 21 ++++++++++++++------- scripts/ui-image.sh | 12 ++++++------ ui/Dockerfile.ui | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86358d0..cf6985d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: release on: push: - tags: ["v*"] + tags: ["v[0-9]*"] permissions: contents: read @@ -27,16 +27,23 @@ jobs: - run: echo "${GITHUB_TOKEN}" | crane auth login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: API image - run: ko build --bare --sbom=none --platform linux/amd64 --tags "${GITHUB_REF_NAME},latest" ./cmd/artifactapi - env: - KO_DOCKER_REPO: ghcr.io/iuclabs/artifactapi - VERSION: ${{ github.ref_name }} - run: npm ci && npm run build working-directory: ui env: BASE_PATH: /ui - name: UI image - run: scripts/ui-image.sh "ghcr.io/iuclabs/artifactapi-ui:${GITHUB_REF_NAME}" latest + run: scripts/ui-image.sh "ghcr.io/iuclabs/artifactapi-ui:${GITHUB_REF_NAME}" env: BASE_PATH: /ui + - name: API image + run: >- + ko build --bare --sbom=none --platform linux/amd64 --tags "${GITHUB_REF_NAME}" + --image-label org.opencontainers.image.source=https://github.com/IUCLabs/artifactapi + ./cmd/artifactapi + env: + KO_DOCKER_REPO: ghcr.io/iuclabs/artifactapi + VERSION: ${{ github.ref_name }} + - name: Move latest + run: | + crane tag "ghcr.io/iuclabs/artifactapi-ui:${GITHUB_REF_NAME}" latest + crane tag "ghcr.io/iuclabs/artifactapi:${GITHUB_REF_NAME}" latest diff --git a/scripts/ui-image.sh b/scripts/ui-image.sh index 0cf28cc..4395518 100755 --- a/scripts/ui-image.sh +++ b/scripts/ui-image.sh @@ -1,11 +1,13 @@ #!/usr/bin/env bash # Daemonless ui/Dockerfile.ui: append the built ui/dist and rendered nginx conf -# onto the nginx base. Usage: scripts/ui-image.sh [extra-tag...] +# onto the nginx base. Usage: scripts/ui-image.sh set -euo pipefail +# Keep in sync with the FROM in ui/Dockerfile.ui. +base=nginx:alpine@sha256:fb4658584bd9a916ffb6f6e365f97c25cfdb2923801f551ea08356e695f14ff7 base_path=${BASE_PATH:-/ui} +source_url=https://github.com/IUCLabs/artifactapi image=$1 -shift root=$(mktemp -d) mkdir -p "$root/usr/share/nginx/html" "$root/etc/nginx/conf.d" @@ -13,7 +15,5 @@ cp -r ui/dist/. "$root/usr/share/nginx/html/" sed "s|\${BASE_PATH}|${base_path}|g" ui/nginx.conf >"$root/etc/nginx/conf.d/default.conf" tar -C "$root" --owner=0 --group=0 --numeric-owner -cf "$root.tar" usr etc -crane append --platform linux/amd64 -b nginx:alpine -f "$root.tar" -t "$image" -for tag in "$@"; do - crane tag "$image" "$tag" -done +crane mutate --platform linux/amd64 "$base" --append "$root.tar" \ + --label "org.opencontainers.image.source=$source_url" -t "$image" diff --git a/ui/Dockerfile.ui b/ui/Dockerfile.ui index 5cb5c57..6333eaf 100644 --- a/ui/Dockerfile.ui +++ b/ui/Dockerfile.ui @@ -11,7 +11,7 @@ ARG BASE_PATH=/ ENV BASE_PATH=${BASE_PATH} RUN npm run build -FROM nginx:alpine +FROM nginx:alpine@sha256:fb4658584bd9a916ffb6f6e365f97c25cfdb2923801f551ea08356e695f14ff7 ARG BASE_PATH=/