## Summary - Add `containers/nettest/default.nix` using `dockerTools.buildLayeredImage` with curl, jq, dnsutils, cacert, and bash — equivalent to the existing Dockerfile - Update `container-tag-and-release` to require `--nix` or `--dockerfile` flag when both build types exist for a container - Update `container-list` to show `[dockerfile+nix]` label when both exist ## Deployment and Testing - [ ] SSH to ringtail, run `nix build -f containers/nettest/default.nix -o result` to verify the nix expression builds - [ ] Tag `nettest-nix-v1.0.0`, confirm `build-container-nix` workflow runs on `nix-container-builder` runner and pushes to registry - [ ] Smoke test on ringtail k3s: `kubectl run nettest --image=registry.ops.eblu.me/blumeops/nettest:v1.0.0 --restart=Never && kubectl logs nettest` - [ ] Verify `mise run container-list` shows `[dockerfile+nix]` for nettest - [ ] Verify `mise run container-tag-and-release nettest v1.1.0` prompts for build type Reviewed-on: https://forge.ops.eblu.me/eblume/blumeops/pulls/214
77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
# Generic container build workflow
|
|
# Triggers on tags matching: <container>-v<version>
|
|
# Builds from containers/<container>/Dockerfile if it exists
|
|
#
|
|
# Uses Dagger to build and push images to the Zot registry.
|
|
#
|
|
# Examples:
|
|
# nettest-v1.0.0 -> builds containers/nettest/
|
|
# devpi-v2.1.0 -> builds containers/devpi/
|
|
# foo-v1.0.0 -> skips if containers/foo/ doesn't exist
|
|
name: Build Container
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*-v[0-9]*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: k8s
|
|
steps:
|
|
- name: Parse tag
|
|
id: parse
|
|
run: |
|
|
TAG="${GITHUB_REF_NAME}"
|
|
echo "Tag: $TAG"
|
|
|
|
# Extract container name (everything before -v)
|
|
# e.g., "nettest-v1.0.0" -> "nettest", "my-app-v2.0.0" -> "my-app"
|
|
CONTAINER="${TAG%-v[0-9]*}"
|
|
VERSION="${TAG#"${CONTAINER}"-}"
|
|
|
|
echo "container=$CONTAINER" >> "$GITHUB_OUTPUT"
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
echo "Container: $CONTAINER"
|
|
echo "Version: $VERSION"
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check if container exists
|
|
id: check
|
|
run: |
|
|
CONTAINER="${{ steps.parse.outputs.container }}"
|
|
CONTEXT="containers/$CONTAINER"
|
|
|
|
if [ -f "$CONTEXT/Dockerfile" ]; then
|
|
echo "Found $CONTEXT/Dockerfile"
|
|
echo "exists=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "No Dockerfile found at $CONTEXT/Dockerfile"
|
|
echo "exists=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Skip if container not found
|
|
if: steps.check.outputs.exists != 'true'
|
|
run: |
|
|
echo "========================================"
|
|
echo "Container not found: ${{ steps.parse.outputs.container }}"
|
|
echo "========================================"
|
|
echo ""
|
|
echo "Tag '${{ github.ref_name }}' does not match any container in containers/"
|
|
echo ""
|
|
echo "Available containers:"
|
|
find containers -maxdepth 1 -mindepth 1 -type d -exec basename {} \; 2>/dev/null | sort | while read -r name; do
|
|
echo " - $name"
|
|
done || echo " (none)"
|
|
echo ""
|
|
echo "Skipping build."
|
|
|
|
- name: Publish
|
|
if: steps.check.outputs.exists == 'true'
|
|
run: |
|
|
dagger call publish \
|
|
--src=. \
|
|
--container-name=${{ steps.parse.outputs.container }} \
|
|
--version=${{ steps.parse.outputs.version }}
|