brewlog/.github/workflows/deploy.yml
Niels Göttsch 423ddc7870
Some checks failed
Build & Publish / Check (push) Successful in 2m15s
Build & Publish / Build & Publish (push) Failing after 9s
ci: build image daemonless with Kaniko (no Docker)
Replace the docker buildx / build-push-action build job with Kaniko running as
the job container: it builds the Dockerfile from the git context and pushes to
the forge registry, with no Docker daemon, no buildx, and no privileged DinD.

Kaniko cannot handle BuildKit `RUN --mount=type=cache`, so drop the two cache
mounts on the cargo build layer (plain `cargo build` now). Document the pipeline
and this gotcha (plus the node20-only runner and full-github-URL action rules) in
the README so it isn't reintroduced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-16 17:17:09 +02:00

102 lines
4 KiB
YAML

name: Build & Publish
# Fork build pipeline for the "zo" forge (git.ziemlichoptimal.de/uberbau/brewlog).
# On every push to `dev` this checks the code, then builds the container and
# publishes it to this forge's own container registry. The moby homelab
# (git.ziemlichoptimal.de/moby/cluster-moby) deploys the resulting image via
# Flux GitOps — this pipeline does NOT deploy anything itself (the upstream
# Fly.io deploy step was removed).
on:
push:
branches: ["dev"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# This forge's built-in container registry, same host as the git server.
REGISTRY: git.ziemlichoptimal.de
IMAGE: git.ziemlichoptimal.de/uberbau/brewlog
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# The repo's mise.toml pulls the whole dev toolchain (tailwind, cargo-watch,
# flyctl, shellcheck, ...), and mise resolves most of those via the GitHub
# API — which 401s on this runner (it has no github.com token), failing the
# entire install. CI only needs the pinned Rust toolchain, so install it
# directly via mise (rust resolves through rustup, no GitHub API).
- name: Install Rust toolchain
uses: https://github.com/jdx/mise-action@v2
with:
install_args: rust
- name: Cache Cargo artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-check
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-
cargo-${{ runner.os }}-
# No sudo on the node:20-bookworm runner image (job runs as root). mold is
# required by .cargo/config.toml's linker flag (-fuse-ld=mold).
- name: Install system dependencies
run: apt-get update && apt-get install -y --no-install-recommends clang lld mold pkg-config
- name: Check formatting
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test -- --show-output
build:
name: Build & Publish
runs-on: ubuntu-latest
needs: [check]
# Build the image DAEMONLESS with Kaniko — no Docker, no buildx, no
# privileged DinD. The job runs *inside* the Kaniko executor image, which
# builds the Dockerfile and pushes straight to the forge registry.
container:
image: gcr.io/kaniko-project/executor:v1.24.0-debug
defaults:
run:
# The kaniko -debug image is busybox-only (no bash).
shell: sh
steps:
- name: Build and push (Kaniko)
env:
# Forgejo auto-provides GITHUB_TOKEN; it can push packages for this
# repo's owner (uberbau) and read this (private-context) git repo.
FORGE_USER: ${{ github.actor }}
FORGE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Kaniko reads these to clone the `--context` git URL.
GIT_USERNAME: ${{ github.actor }}
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: |
set -eu
# Registry auth for the push (docker config.json format).
AUTH=$(printf '%s:%s' "$FORGE_USER" "$FORGE_TOKEN" | base64 | tr -d '\n')
mkdir -p /kaniko/.docker
printf '{"auths":{"%s":{"auth":"%s"}}}' "$REGISTRY" "$AUTH" > /kaniko/.docker/config.json
# Kaniko clones the context itself (this job has no node for JS actions
# like checkout). `dev` is the moving branch tag; the commit SHA is the
# immutable ref the moby Deployment pins by digest.
/kaniko/executor \
--context "git://${REGISTRY}/uberbau/brewlog.git#refs/heads/dev" \
--dockerfile Dockerfile \
--destination "${IMAGE}:${GITHUB_SHA}" \
--destination "${IMAGE}:dev"