ci(390): add shared CI toolchain image (.NET 10 SDK + Node 22 + prod ffmpeg)
Build CI Toolchain Image / Build & push CI image (push) Failing after 1m42s
Build CI Toolchain Image / Build & push CI image (push) Failing after 1m42s
Layers the .NET 10 SDK + Node 22 onto our own ersatztv-ffmpeg base (the same COPY --from=.../usr/share/dotnet pattern docker/Dockerfile uses for prod), and bakes the dotnet-ef + reportgenerator global tools the jobs installed per run. Builds/pushes 192.168.1.95:3000/timothy/ersatztv-ci:<sha> via a separate workflow so a ~2GB toolchain image isn't rebuilt on every commit. Refs #390
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
name: Build CI Toolchain Image
|
||||
|
||||
# Builds the shared CI toolchain image (.NET 10 SDK + Node 22 + prod-identical ffmpeg) and
|
||||
# pushes it to the Gitea container registry (ersatztv#390). The toolchain jobs in
|
||||
# docker-build.yml consume it via `container:`, pinned to an immutable :<sha>.
|
||||
#
|
||||
# push touching docker/ci/** -> :<short-sha> (+ :latest only from main)
|
||||
# workflow_dispatch -> manual rebuild
|
||||
# schedule (weekly) -> picks up base-image security updates
|
||||
#
|
||||
# Deliberately separate from docker-build.yml: this image changes rarely (a Dockerfile edit or
|
||||
# the weekly cron), while docker-build.yml runs on every push/PR. Coupling them would rebuild a
|
||||
# ~2GB toolchain image on every commit.
|
||||
#
|
||||
# ROLLOUT NOTE: the jobs pin an immutable :<sha>, never :latest — a broken toolchain image would
|
||||
# otherwise block every converted job the moment it was pushed. Bumping the toolchain is therefore
|
||||
# a deliberate two-step: merge a docker/ci/Dockerfile change (this workflow publishes a new :<sha>),
|
||||
# then update the pin in docker-build.yml in a follow-up PR whose CI proves the new image works.
|
||||
# See docs/ci-cd.md -> "CI toolchain image".
|
||||
#
|
||||
# Like docker-build.yml: the Gitea registry is HTTP-only, so BuildKit needs the inline
|
||||
# `http = true` config (it does not inherit the host daemon's insecure-registries setting).
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- 'docker/ci/Dockerfile'
|
||||
- '.gitea/workflows/ci-image.yml'
|
||||
schedule:
|
||||
# Mondays 05:00 UTC — an hour before the dependency scan, so a fresh toolchain is in place
|
||||
# before the week's runs. Gitea registers `schedule` only from the default branch (main).
|
||||
- cron: '0 5 * * 1'
|
||||
|
||||
# Serialize per ref: concurrent builds would race on the shared :buildcache tag.
|
||||
# No cancel-in-progress — a half-pushed toolchain image is worse than a redundant build.
|
||||
concurrency:
|
||||
group: ersatztv-ci-image-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
REGISTRY: 192.168.1.95:3000
|
||||
CI_IMAGE: 192.168.1.95:3000/timothy/ersatztv-ci
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build & push CI image
|
||||
# `small` = the small-jobs runner lane. This is a docker-only job (no toolchain needed —
|
||||
# it *builds* the toolchain), same as docker-build.yml's `build` job.
|
||||
runs-on: small
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# only docker/ci/Dockerfile is needed; no git describe/log here
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Compute tags
|
||||
id: meta
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SHORT=$(git rev-parse --short HEAD)
|
||||
# Always publish the immutable :<sha> — that is what docker-build.yml pins.
|
||||
TAGS=("${CI_IMAGE}:${SHORT}")
|
||||
# :latest is a convenience/floating pointer for humans and the weekly rebuild; jobs must
|
||||
# never consume it. Only main may move it.
|
||||
if [ "${GITHUB_REF}" = "refs/heads/main" ]; then
|
||||
TAGS+=("${CI_IMAGE}:latest")
|
||||
fi
|
||||
echo "short=${SHORT}" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo "tags<<__EOT__"
|
||||
printf '%s\n' "${TAGS[@]}"
|
||||
echo "__EOT__"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
printf 'tag: %s\n' "${TAGS[@]}"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
with:
|
||||
buildkitd-config-inline: |
|
||||
[registry."192.168.1.95:3000"]
|
||||
http = true
|
||||
|
||||
- name: Login to Gitea registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: ./docker/ci/Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
provenance: false
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
cache-from: type=registry,ref=192.168.1.95:3000/timothy/ersatztv-ci:buildcache
|
||||
cache-to: type=registry,ref=192.168.1.95:3000/timothy/ersatztv-ci:buildcache,mode=max,ignore-error=true
|
||||
|
||||
# The Dockerfile's own build-time smoke test (dotnet --info, node, ffmpeg, ...) already ran
|
||||
# inside the build. This re-checks the *pushed* artifact end-to-end: that the registry copy
|
||||
# pulls and its toolchain runs, which is exactly what `container:` will do on every job.
|
||||
- name: Verify the pushed image
|
||||
run: |
|
||||
set -euo pipefail
|
||||
IMG="${CI_IMAGE}:${{ steps.meta.outputs.short }}"
|
||||
echo "Pulling ${IMG}"
|
||||
docker pull "$IMG"
|
||||
docker run --rm --entrypoint /bin/bash "$IMG" -euxc '
|
||||
dotnet --version
|
||||
dotnet ef --version
|
||||
reportgenerator --version
|
||||
node --version
|
||||
ffmpeg -version | head -1
|
||||
git --version
|
||||
python3 --version
|
||||
'
|
||||
echo "CI image OK. Pin this in .gitea/workflows/docker-build.yml -> CI_IMAGE_REF:"
|
||||
echo " ${IMG}"
|
||||
@@ -0,0 +1,91 @@
|
||||
# Shared CI toolchain image (ersatztv#390) — .NET 10 SDK + Node 22 + prod-identical ffmpeg.
|
||||
#
|
||||
# Built/pushed by .gitea/workflows/ci-image.yml to 192.168.1.95:3000/timothy/ersatztv-ci.
|
||||
# The toolchain jobs in docker-build.yml run *inside* this image via `container:`, so they
|
||||
# install nothing at run time: no setup-dotnet, no setup-node, no `apt-get install ffmpeg`,
|
||||
# no `dotnet tool install`. Project dependencies (NuGet/npm) are NOT baked in — those change
|
||||
# per commit and stay on actions/cache.
|
||||
#
|
||||
# Layering rationale: we start from our OWN ffmpeg base and copy the .NET SDK on top, which is
|
||||
# exactly the pattern docker/Dockerfile uses for the prod image (`FROM ersatztv-ffmpeg` +
|
||||
# `COPY --from=dotnet-runtime /usr/share/dotnet`). That base is ghcr.io/linuxserver/baseimage-ubuntu:noble,
|
||||
# the same Ubuntu release as mcr.microsoft.com/dotnet/sdk:10.0-noble, so the copied SDK matches
|
||||
# the base's glibc/ICU. It also gives CI the *prod* ffmpeg build rather than a generic apt one —
|
||||
# the fidelity that the ersatztv#299 seeded-media/scanner E2E follow-ups will need.
|
||||
#
|
||||
# Keep the pins below in sync with what CI actually needs; Renovate tracks the image pins
|
||||
# (see renovate.json). The two dotnet tool versions mirror what docker-build.yml used to
|
||||
# `dotnet tool install` per run — bump them here, not in the workflow.
|
||||
|
||||
# Bumping FFMPEG_TAG: keep it equal to the tag docker/Dockerfile pins, so CI's ffmpeg stays
|
||||
# prod-identical. Renovate manages that Dockerfile's pin; mirror it here.
|
||||
FROM --platform=linux/amd64 192.168.1.95:3000/timothy/ersatztv-ffmpeg:8.1.2 AS ci-base
|
||||
|
||||
# The ffmpeg base sets ENTRYPOINT ["ffmpeg"] / CMD ["--help"] because it ships as an ffmpeg CLI.
|
||||
# This image is a CI *job container*: the runner starts it long-lived and execs steps into it,
|
||||
# so an ffmpeg entrypoint is wrong here. Reset both.
|
||||
ENTRYPOINT []
|
||||
CMD ["/bin/bash"]
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Toolchain the workflow steps and the actions themselves need:
|
||||
# git — actions/checkout
|
||||
# ca-certificates, curl — NodeSource setup + general fetches
|
||||
# tar, zstd, unzip, xz — actions/cache archive round-trip
|
||||
# python3 — scripts/generate-endpoint-index.py (the api-docs job)
|
||||
# jq — ad-hoc JSON in CI steps
|
||||
# The ffmpeg base is a runtime image, so none of these are guaranteed present.
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
git \
|
||||
jq \
|
||||
python3 \
|
||||
tar \
|
||||
unzip \
|
||||
xz-utils \
|
||||
zstd && \
|
||||
apt-get clean -y && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Node 22 (NodeSource) — matches the `node-version: '22.x'` the workflow used to request from
|
||||
# setup-node, and the node:22 base docker/Dockerfile builds the SPA with. act_runner also needs a
|
||||
# `node` on PATH inside the job container to execute JavaScript actions (actions/checkout, cache).
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
|
||||
apt-get install -y --no-install-recommends nodejs && \
|
||||
apt-get clean -y && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# .NET 10 SDK. Copied from the official SDK image rather than dotnet-install.sh: same mechanism as
|
||||
# docker/Dockerfile's runtime copy, one pinned artifact, no install script to fail at build time.
|
||||
# global.json pins sdk 10.0.0 with rollForward latestMinor, which this satisfies.
|
||||
COPY --from=mcr.microsoft.com/dotnet/sdk:10.0-noble-amd64 /usr/share/dotnet /usr/share/dotnet
|
||||
|
||||
ENV DOTNET_ROOT=/usr/share/dotnet \
|
||||
PATH="/usr/share/dotnet:/root/.dotnet/tools:${PATH}" \
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT=1 \
|
||||
DOTNET_NOLOGO=1 \
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
|
||||
# Global dotnet tools the jobs used to install per run (5s + ~4s each, every run, forever).
|
||||
# dotnet-ef — the migrations job (was: `dotnet tool install --global dotnet-ef --version 9.0.12`)
|
||||
# dotnet-reportgenerator-globaltool — the test job's coverage summary
|
||||
# Baked here so the versions live in one tracked place instead of inline workflow strings.
|
||||
RUN dotnet tool install --global dotnet-ef --version 9.0.12 && \
|
||||
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.5.10
|
||||
|
||||
# Build-time smoke test: fail the IMAGE build, not a CI run, if any part of the toolchain is
|
||||
# unusable. Notably `dotnet --info` catches a missing ICU/glibc dependency in the base — the one
|
||||
# real risk of copying the SDK onto a non-Microsoft base.
|
||||
RUN set -eux; \
|
||||
dotnet --info; \
|
||||
dotnet ef --version; \
|
||||
reportgenerator --version; \
|
||||
node --version; \
|
||||
npm --version; \
|
||||
git --version; \
|
||||
python3 --version; \
|
||||
ffmpeg -version; \
|
||||
ffprobe -version
|
||||
Reference in New Issue
Block a user