From d1c7c557002a886e6bcbb8742bfd527f8a9d2a39 Mon Sep 17 00:00:00 2001 From: Job Date: Sun, 22 Nov 2026 17:48:04 +0000 Subject: [PATCH] Run jobs in our own job image mkosi.images/job/ builds an OCI image with git, Node.js 26 and dnf, and the OS ships it in /usr, so it is signed and updated with the OS. gitea-runner.service loads it at boot instead of pulling Fedora, and JavaScript actions work without installing Node.js in each job. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/os.yml | 6 ++--- README.md | 3 ++- mkosi.conf | 7 ++++++ mkosi.extra/etc/gitea-runner/config.yaml | 4 +++- .../lib/systemd/system/gitea-runner.service | 9 ++++---- .../usr/lib/tmpfiles.d/gitea-runner.conf | 2 +- mkosi.images/job/mkosi.conf | 22 +++++++++++++++++++ 7 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 mkosi.images/job/mkosi.conf diff --git a/.gitea/workflows/os.yml b/.gitea/workflows/os.yml index e73f4e8..1242eb4 100644 --- a/.gitea/workflows/os.yml +++ b/.gitea/workflows/os.yml @@ -26,9 +26,9 @@ jobs: packages: write steps: - name: Install tools - run: dnf install -yq mkosi git-core - # Check out fetches the commit with git, which needs no Node.js and no - # action from GitHub. gitea-runner 6 removed builtin:checkout. + run: dnf install -yq mkosi + # Check out fetches the commit with git, so it needs no action from + # GitHub. gitea-runner 6 removed builtin:checkout. - name: Check out env: AUTH: "Authorization: token ${{ gitea.token }}" diff --git a/README.md b/README.md index e3d5e17..e2858d0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ image. - **Encrypted with a TPM:** everything that isn't read-only, such as `/etc` and `/var`, is encrypted. The TPM unlocks it only for correctly signed UKIs. - **Jobs in containers:** each job runs in its own privileged container on - root's podman, by default in plain Fedora (`runs-on: linux`). Privileged + root's podman. Jobs with `runs-on: linux` run in our job image: Fedora with + git, Node.js 26 and dnf, built with the OS and shipped in `/usr`. Privileged jobs can build OS images, but can also take over the VM, so only use it for repositories you trust. Container storage is wiped at every boot. - **Self-updating:** the image rebuilds weekly. The VM lets running jobs finish diff --git a/mkosi.conf b/mkosi.conf index a57e886..83efa6c 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -9,6 +9,11 @@ # - mkosi.prepare installs the runner, which Fedora doesn't package. # - mkosi.finalize keeps /etc in /usr/share/factory/etc. # - mkosi.version gives each build its version. +# - mkosi.images/job/ builds the job image. + +[Config] +# Dependencies builds the job image first, so ExtraTrees= can copy it in. +Dependencies=job [Distribution] Distribution=fedora @@ -28,6 +33,7 @@ ManifestFormat=json # the name the runner registers with. # - WithDocs leaves out man pages. The image has no man to read them. # - Packages lists the packages installed into the image. +# - ExtraTrees copies the job image (mkosi.images/job/) into /usr. # - UnifiedKernelImageFormat names the UKI runneros_.efi, which # matches the MatchPattern= of mkosi.extra/usr/lib/sysupdate.d/20-uki.transfer. # - KernelCommandLine: @@ -70,6 +76,7 @@ Packages= curl procps-ng iproute +ExtraTrees=%O/job:/usr/lib/runneros/job UnifiedKernelImageFormat=%i_%v KernelCommandLine= quiet diff --git a/mkosi.extra/etc/gitea-runner/config.yaml b/mkosi.extra/etc/gitea-runner/config.yaml index 212d9cf..7510717 100644 --- a/mkosi.extra/etc/gitea-runner/config.yaml +++ b/mkosi.extra/etc/gitea-runner/config.yaml @@ -11,8 +11,10 @@ runner: # shutdown_timeout lets running jobs finish when the runner stops, as it # does before an update reboots the machine. shutdown_timeout: 1h + # labels names the job image of jobs with runs-on: linux, which + # gitea-runner.service loads at boot. labels: - - linux:docker://quay.io/fedora/fedora:45 + - linux:docker://localhost/runneros-job container: # privileged lets jobs build OS images, as this repository's own workflow # does. A job can then take over the machine, so only run jobs you trust. diff --git a/mkosi.extra/usr/lib/systemd/system/gitea-runner.service b/mkosi.extra/usr/lib/systemd/system/gitea-runner.service index 5e55291..f713d0f 100644 --- a/mkosi.extra/usr/lib/systemd/system/gitea-runner.service +++ b/mkosi.extra/usr/lib/systemd/system/gitea-runner.service @@ -14,10 +14,11 @@ Requires=podman.socket # HOME holds the cache of actions/cache, next to the registration. Environment=HOME=/var/lib/gitea-runner Environment=DOCKER_HOST=unix:///run/podman/podman.sock -# ExecStartPre pulls the image of the linux label in -# /etc/gitea-runner/config.yaml, so the first job after a boot doesn't wait -# for it. The runner still starts if it fails. -ExecStartPre=-/usr/bin/podman pull -q quay.io/fedora/fedora:45 +# ExecStartPre loads the job image (mkosi.images/job/) from /usr into podman, +# whose storage is wiped at every boot, under the name that the linux label in +# /etc/gitea-runner/config.yaml uses. podman names nothing it pulls from an +# OCI directory, hence the tag. +ExecStartPre=/bin/sh -c 'podman tag "$(podman pull -q oci:/usr/lib/runneros/job)" localhost/runneros-job' ExecStart=/usr/bin/gitea-runner -c /etc/gitea-runner/config.yaml daemon Restart=on-failure RestartSec=10s diff --git a/mkosi.extra/usr/lib/tmpfiles.d/gitea-runner.conf b/mkosi.extra/usr/lib/tmpfiles.d/gitea-runner.conf index 1903e45..9763405 100644 --- a/mkosi.extra/usr/lib/tmpfiles.d/gitea-runner.conf +++ b/mkosi.extra/usr/lib/tmpfiles.d/gitea-runner.conf @@ -3,5 +3,5 @@ d /var/lib/gitea-runner 0700 # The storage of root's podman is wiped at every boot, so images and leftovers -# of jobs don't pile up. Jobs pull their images again. +# of jobs don't pile up. gitea-runner.service loads the job image again. R /var/lib/containers/storage diff --git a/mkosi.images/job/mkosi.conf b/mkosi.images/job/mkosi.conf new file mode 100644 index 0000000..837dbeb --- /dev/null +++ b/mkosi.images/job/mkosi.conf @@ -0,0 +1,22 @@ +# mkosi.conf builds the job image, the container that jobs with +# runs-on: linux run in. It is an OCI image, which the OS ships in +# /usr/lib/runneros/job (ExtraTrees= in /mkosi.conf), so it is signed and +# updated with the OS. gitea-runner.service loads it into podman at boot. +# +# Packages holds what common actions need. Jobs install more with dnf. +[Output] +Format=oci +Output=job + +[Content] +WithDocs=no +Packages= + dnf5 # Jobs install what else they need. + fedora-repos # dnf needs to know the repositories. + git-core # Checkouts are done with git. + nodejs26 # JavaScript actions run on node. + curl + tar # actions/cache and artifacts use these. + gzip + zstd + findutils