Files
2026-06-21 09:18:22 +00:00

111 lines
4.1 KiB
YAML

#
# .gitea/workflows/spdk-image.yaml
#
# Builds the SPDK NVMe/TCP target image (serving stack) from serving/spdk and
# pushes it to the registry, so serving hosts just `docker compose pull` it.
# There is no official spdk/spdk image to pull, so we compile a pinned release
# once here (slow: ~10-20 min, needs a runner with enough CPU/RAM/disk).
#
# Runs only when the SPDK image inputs change (path filter) or on demand — not
# on every commit. Bump SPDK_VERSION (or use the manual run input) to roll SPDK.
#
# Builds off ANY branch (dev branches welcome); the SPDK release (SPDK_VERSION /
# the dispatch input) is the --build-arg and the base tag. To avoid clobbering
# the main image, dev branches push "<spdk-ver>-<branch>-<sha7>" and never move
# :latest:
# - tag / main push -> "<spdk-ver>" (+ :latest)
# - branch push -> "<spdk-ver>-<branch>-<sha7>" (dev image, no :latest)
# Set SPDK_VERSION in serving/.env to the tag you want to run.
#
# Required Gitea repo secrets: PACKAGE_USER, PACKAGE_TOKEN (registry creds).
#
name: Build SPDK NVMe-oF image
run-name: ${{ gitea.actor }} builds the SPDK NVMe/TCP target image (${{ gitea.ref_name }})
on:
push:
branches:
- "**" # every branch — dev branches get a disambiguated tag
tags:
- "v*"
paths:
- "serving/spdk/**"
- ".gitea/workflows/spdk-image.yaml"
workflow_dispatch:
inputs:
spdk_version:
description: "SPDK release tag (https://github.com/spdk/spdk/releases)"
required: false
default: "v24.09"
# One (slow) build per ref at a time; a newer push to the same ref cancels it.
concurrency:
group: spdk-image-${{ gitea.ref }}
cancel-in-progress: true
env:
SPDK_IMAGE: "git.bitasylum.org/audiobuzz/spdk-nvmf"
SPDK_VERSION: "v24.09" # default SPDK release for push-triggered builds
jobs:
spdk-build:
name: Build & push SPDK image
runs-on: ubuntu-latest
container:
image: git.bitasylum.org/audiobuzz/ubuntu-act-runner-qemu:main
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Install buildah
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends buildah
-
name: Registry login
run: |
buildah login \
--username "${{ secrets.PACKAGE_USER }}" \
--password "${{ secrets.PACKAGE_TOKEN }}" \
git.bitasylum.org
-
name: Build & push
# vfs storage (overlay-on-overlayfs is unsupported in-container) and
# chroot isolation (so the Dockerfile's RUN/compile steps work without
# nested user namespaces).
env:
STORAGE_DRIVER: vfs
BUILDAH_ISOLATION: chroot
run: |
# SPDK release: the --build-arg + base tag (dispatch input wins).
SVER="${{ inputs.spdk_version || env.SPDK_VERSION }}"
short_sha="$(echo "${GITHUB_SHA}" | cut -c1-7)"
# main / release tags -> "<spdk-ver>" + :latest; dev branches ->
# "<spdk-ver>-<branch>-<sha7>", no :latest (so they don't clobber main).
if [ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ] || [ "$GITHUB_REF" = "refs/heads/main" ]; then
TAG="$SVER"; push_latest=true
else
branch="${GITHUB_REF#refs/heads/}"
safe_branch=$(printf '%s' "$branch" \
| sed -e 's#[^A-Za-z0-9._-]#-#g' -e 's#^[.-]*##' | cut -c1-80)
[ -n "$safe_branch" ] || safe_branch="branch"
TAG="${SVER}-${safe_branch}-${short_sha}"; push_latest=false
fi
echo "Building ${SPDK_IMAGE}:${TAG} (SPDK $SVER, latest=$push_latest)"
buildah bud \
--build-arg SPDK_VERSION="$SVER" \
-t "${SPDK_IMAGE}:${TAG}" \
serving/spdk
buildah push "${SPDK_IMAGE}:${TAG}"
if [ "$push_latest" = "true" ]; then
buildah tag "${SPDK_IMAGE}:${TAG}" "${SPDK_IMAGE}:latest"
buildah push "${SPDK_IMAGE}:latest"
echo "Updated ${SPDK_IMAGE}:latest"
else
echo "Dev branch build — :latest left untouched (run with SPDK_VERSION=${TAG})"
fi