Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd98edbf3e | ||
|
|
0d54f59ff6 | ||
|
|
57dd1afd2f | ||
|
|
3b10f60fab | ||
|
|
52b4cea73e | ||
|
|
6ebddf18ce | ||
|
|
018f15172d | ||
|
|
094ee671d7 | ||
|
|
1c906b9b68 | ||
|
|
edc55ca97c | ||
|
|
676a9978f8 | ||
|
|
d76d28ef8a | ||
|
|
d1c7c55700 | ||
|
|
460bdbe380 | ||
|
|
821065c428 | ||
|
|
e2a74d4e16 | ||
|
|
a0bfce38da | ||
|
|
6a32e00431 | ||
|
|
b5aa2d7a59 | ||
|
|
95e0420207 | ||
|
|
e2a873f883 | ||
|
|
0733ff55f3 | ||
|
|
0569bce676
|
||
|
|
f3dfbb4f78
|
||
|
|
92a21ae607
|
||
|
|
607987ebbd
|
||
|
|
7df16dce11
|
||
|
|
cd8dfd52f8
|
||
|
|
29ac7278a1
|
||
|
|
5bb84ade05
|
||
|
|
5f2a5c2b23 | ||
|
|
fd1ef420cd | ||
|
|
5512061b2e | ||
|
|
042583be77 | ||
|
|
cdc4a84658 | ||
|
|
b0a49de3e6
|
||
|
|
c2ec9ddb29
|
||
|
|
97355554f4
|
||
|
|
7b26dd92d1
|
||
|
|
dfa5d69b44
|
No files matched your search
@@ -1,28 +0,0 @@
|
||||
# git-runner job image
|
||||
#
|
||||
# Builds the job image (job/) and pushes it to this Gitea's registry.
|
||||
# Runs on every push, weekly for Fedora updates, and by hand.
|
||||
name: job
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "0 2 * * 0" # weekly (Sunday), picks up Fedora updates
|
||||
workflow_dispatch: # run by hand, e.g. for a CVE
|
||||
|
||||
jobs:
|
||||
job:
|
||||
runs-on: fedora
|
||||
env:
|
||||
IMAGE: git.plabble.org/job79/git-runner-mkosi-job:latest
|
||||
steps:
|
||||
- name: Install tools
|
||||
run: dnf install -yq git-core podman
|
||||
- name: Check out
|
||||
uses: builtin:checkout
|
||||
- name: Build
|
||||
run: podman build -t "$IMAGE" job
|
||||
- name: Log in to the registry
|
||||
run: podman login -u "${{ github.repository_owner }}" --password-stdin git.plabble.org <<<"${{ secrets.GITHUB_TOKEN }}"
|
||||
- name: Push
|
||||
run: podman push --compression-format=zstd:chunked "$IMAGE"
|
||||
+39
-35
@@ -1,58 +1,62 @@
|
||||
# git-runner OS image
|
||||
# os.yml builds the OS image and publishes it as version "latest". VMs fetch
|
||||
# the built images as updates (mkosi.extra/usr/lib/sysupdate.d). It runs on
|
||||
# every push, weekly for package updates, and by hand for critical CVEs.
|
||||
#
|
||||
# Builds the OS image with mkosi, signed for Secure Boot, and publishes it in this Gitea's generic
|
||||
# package registry, where runners fetch their updates (mkosi.extra/usr/lib/sysupdate.d):
|
||||
# https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
|
||||
# Runs on every push, weekly for Fedora updates, and by hand. The weekly and manual runs also
|
||||
# publish the disk image for new installs (git-runner.qcow2 in the same place).
|
||||
#
|
||||
# Secrets:
|
||||
# - SECUREBOOT_KEY the private key for mkosi.crt
|
||||
# Required values:
|
||||
# - SECUREBOOT_KEY repository secret: the private key of mkosi.crt, written
|
||||
# to mkosi.key.
|
||||
# - SIGNING_KEY repository secret: the armored private gpg key whose
|
||||
# public half is mkosi.extra/usr/lib/systemd/
|
||||
# import-pubring.pgp, which systemd-sysupdate checks.
|
||||
# - PACKAGE_TOKEN repository secret: a token of the package owner with only
|
||||
# write:package. The job token can't write packages.
|
||||
name: os
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "0 2 * * 0" # weekly (Sunday), picks up Fedora updates
|
||||
workflow_dispatch: # run by hand, e.g. for a CVE
|
||||
- cron: "0 2 * * 0"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
os:
|
||||
runs-on: fedora
|
||||
env:
|
||||
PACKAGE: https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest
|
||||
AUTH: ${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}
|
||||
runs-on: linux
|
||||
steps:
|
||||
- name: Install tools
|
||||
run: dnf install -yq git-core mkosi jq
|
||||
run: dnf install -yq mkosi
|
||||
- name: Check out
|
||||
uses: builtin:checkout
|
||||
uses: actions/checkout@v7
|
||||
- name: Build
|
||||
env:
|
||||
SECUREBOOT_KEY: ${{ secrets.SECUREBOOT_KEY }}
|
||||
KEY: ${{ secrets.SECUREBOOT_KEY }}
|
||||
run: |
|
||||
(umask 077; printenv SECUREBOOT_KEY > mkosi.key)
|
||||
mkosi --secure-boot=yes build
|
||||
(umask 077 && printf '%s\n' "$KEY" > mkosi.key)
|
||||
mkosi build
|
||||
- name: Compress
|
||||
working-directory: mkosi.output
|
||||
run: |
|
||||
zstd -q --rm -T0 -19 git-runner_*.usr-*.raw
|
||||
sha256sum git-runner_*.efi git-runner_*.usr-*.raw.zst > SHA256SUMS
|
||||
- name: Publish the update
|
||||
zstd -q --rm -9 runneros_*.usr-*.raw
|
||||
- name: Checksum
|
||||
working-directory: mkosi.output
|
||||
run: |
|
||||
for f in $(awk '{print $2}' SHA256SUMS); do curl -fsS -u "$AUTH" --upload-file "$f" "$PACKAGE/$f"; done
|
||||
curl -fsS -u "$AUTH" -X DELETE "$PACKAGE/SHA256SUMS" || true
|
||||
curl -fsS -u "$AUTH" --upload-file SHA256SUMS "$PACKAGE/SHA256SUMS"
|
||||
- name: Remove older versions
|
||||
run: sha256sum runneros_*.efi runneros_*.usr-*.raw.zst > SHA256SUMS
|
||||
- name: Sign
|
||||
working-directory: mkosi.output
|
||||
env:
|
||||
KEY: ${{ secrets.SIGNING_KEY }}
|
||||
run: |
|
||||
curl -fsS -u "$AUTH" https://git.plabble.org/api/v1/packages/job79/generic/git-runner-mkosi/latest/files | jq -r '.[].name' | grep '^git-runner_' |
|
||||
grep -vxFf <(awk '{print $2}' SHA256SUMS) | while read -r f; do curl -fsS -u "$AUTH" -X DELETE "$PACKAGE/$f"; done
|
||||
- name: Publish the disk image
|
||||
if: github.event_name != 'push'
|
||||
export GNUPGHOME=$(mktemp -d)
|
||||
gpg -q --batch --import <<< "$KEY"
|
||||
gpg -q --batch -o SHA256SUMS.gpg --detach-sign SHA256SUMS
|
||||
- name: Build qcow2
|
||||
working-directory: mkosi.output
|
||||
run: qemu-img convert -c -O qcow2 "$(basename runneros_*.efi .efi).raw" runneros.qcow2
|
||||
- name: Publish
|
||||
working-directory: mkosi.output
|
||||
env:
|
||||
PKG: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/runneros/latest
|
||||
AUTH: "Authorization: token ${{ secrets.PACKAGE_TOKEN }}"
|
||||
run: |
|
||||
qemu-img convert -c -O qcow2 "$(basename git-runner_*.efi .efi).raw" git-runner.qcow2
|
||||
curl -fsS -u "$AUTH" -X DELETE "$PACKAGE/git-runner.qcow2" || true
|
||||
curl -fsS -u "$AUTH" --upload-file git-runner.qcow2 "$PACKAGE/git-runner.qcow2"
|
||||
curl -fsS -H "$AUTH" -X DELETE "$PKG" || true
|
||||
for f in runneros_*.efi runneros_*.usr-*.raw.zst runneros.qcow2 runneros_*.manifest SHA256SUMS.gpg SHA256SUMS; do
|
||||
curl -fsS -o /dev/null -H "$AUTH" --upload-file "$f" "$PKG/$f"
|
||||
done
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
# Build outputs, and the Secure Boot key for local signed builds.
|
||||
mkosi.output/
|
||||
mkosi.key
|
||||
mkosi.output/
|
||||
mkosi.cache/
|
||||
mkosi.credentials/
|
||||
@@ -0,0 +1,102 @@
|
||||
# Agent notes
|
||||
|
||||
How to build and test this image as a coding agent. Follow [Style](#style) for
|
||||
every change.
|
||||
|
||||
## Style
|
||||
|
||||
- Keep it simple. Prefer fewer files and fewer lines. Delete what isn't
|
||||
needed. Write plain English in short sentences.
|
||||
- Follow the defaults and conventions of each tool and language. Only set an
|
||||
option when the default doesn't work.
|
||||
- Each fact lives in one place. Elsewhere, refer to it instead of repeating it.
|
||||
- Divide code and config into parts (files, directories, sections) that each
|
||||
stand on their own: reading one part alone tells you what it does and why.
|
||||
- Name each part for what it does. A part without a good name holds things
|
||||
that don't belong together.
|
||||
- A little copying beats a little dependency. Repeat a small piece rather than
|
||||
share it or pull it in from elsewhere.
|
||||
|
||||
### File header
|
||||
|
||||
A file starts with a header, after the shebang if there is one. Leave it out
|
||||
when the name already says it all, as with `.gitignore`. A part made of
|
||||
many files, like a package, needs it in only one file. For example:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
# mkosi.version prints the build time in UTC (YYYYMMDDhhmm) and the git
|
||||
# commit. Every build gets a higher version than the one before, which is how
|
||||
# systemd-sysupdate tells that an update is newer. The commit tells which
|
||||
# source an image was built from.
|
||||
```
|
||||
|
||||
- The first sentence starts with the name of the part the file is, and says
|
||||
what it does. That is the name the language or tool uses for it, such as a
|
||||
file name or a package name.
|
||||
- The rest says why, naming the files it works with by path.
|
||||
|
||||
Files that can't hold comments (JSON, `subuid`, `machine-id`) are explained in
|
||||
the file that uses them.
|
||||
|
||||
### Comments
|
||||
|
||||
- Explain why, not what. Leave out comments that only repeat the code. Try to
|
||||
write clean code instead of comments.
|
||||
- Write full sentences that start with the name of what they describe:
|
||||
`# ManifestFormat lists the packages and versions in the image.` or
|
||||
`# link prints the tmpfiles line for /etc/$1.`
|
||||
- Put a comment right above the line or block it is about. A short note on
|
||||
one line may go at the end of that line, as a full sentence too.
|
||||
- Separate paragraphs and lists with a line holding only the comment
|
||||
character.
|
||||
- Wrap comments at 80 columns.
|
||||
|
||||
## Testing
|
||||
|
||||
`mkosi vm` boots the image in qemu. It needs systemd on the host, so run mkosi
|
||||
in a privileged podman container that boots systemd:
|
||||
|
||||
```sh
|
||||
podman build -t mkosi-vm - <<'END'
|
||||
FROM registry.fedoraproject.org/fedora:45
|
||||
RUN dnf install -y mkosi git-core qemu-system-x86-core edk2-ovmf swtpm-tools \
|
||||
virtiofsd openssl
|
||||
CMD ["/sbin/init"]
|
||||
END
|
||||
podman run -d --name mkosi --privileged --systemd=always -v <repo>:/repo \
|
||||
-v mkosi-cache:/root/.cache/mkosi -v mkosi-work:/var/tmp -w /repo mkosi-vm
|
||||
podman exec mkosi mkosi -f genkey # Run this once. Don't commit mkosi.crt.
|
||||
podman exec mkosi mkdir -p mkosi.cache
|
||||
podman exec -d -t mkosi sh -c 'mkosi -i -f --kernel-command-line-extra="\
|
||||
console=ttyS0 systemd.journald.forward_to_console=1" vm -- \
|
||||
-serial chardev:console > mkosi.output/vm.log 2>&1'
|
||||
```
|
||||
|
||||
- To register the test VM, register on the host with
|
||||
`gitea-runner register --no-interactive --instance <url> --token <token>`
|
||||
and pass the `.runner` it writes as a tmpfiles.extra credential:
|
||||
`printf 'f~ /var/lib/gitea-runner/.runner 0600 - - - %s' "$(base64 -w0
|
||||
.runner)" > mkosi.credentials/tmpfiles.extra`. mkosi passes each file in
|
||||
mkosi.credentials/ as a credential of its name. The runner then shows up in
|
||||
Gitea, and its jobs show whether it works.
|
||||
- `mkosi -i` keeps the image with its packages installed in `mkosi.cache/`.
|
||||
Rebuilds start from it and skip installing packages.
|
||||
- The volume `mkosi-work` keeps mkosi's workspace in /var/tmp off overlayfs.
|
||||
When mkosi copies files with SELinux labels to overlayfs, it drops all
|
||||
xattrs, such as file capabilities.
|
||||
- `mkosi vm` needs a terminal, hence `-d -t`. Its console goes to the log.
|
||||
- The console of `mkosi vm` is hvc0, which the kernel can only use once the
|
||||
initrd loads its driver. `console=ttyS0` also sends the kernel log to the
|
||||
serial port, and `-serial chardev:console` sends that port to the same log.
|
||||
The log then shows early errors too, such as a panic or an initrd that
|
||||
can't find /usr. `systemd.journald.forward_to_console=1` adds the journal,
|
||||
as the image has no sshd. Arguments after `--` go to qemu.
|
||||
|
||||
`mkosi.version` gives each run a new version, so `mkosi vm` without `-f` fails
|
||||
with "has not been built yet". To boot an existing build again, pin its version
|
||||
from `mkosi.output/runneros_<version>.raw`:
|
||||
|
||||
```sh
|
||||
mkosi --image-version 202611221555.0569bce vm
|
||||
```
|
||||
@@ -0,0 +1,47 @@
|
||||
# runneros
|
||||
|
||||
A VM that runs a [Gitea Actions](https://docs.gitea.com/usage/actions/overview)
|
||||
runner. It is a minimal Fedora image built with
|
||||
[mkosi](https://github.com/systemd/mkosi), and it builds and publishes its own
|
||||
image.
|
||||
|
||||
- **Read-only OS:** `/usr` is read-only. Secure Boot verifies the UKI (kernel,
|
||||
initrd and command line), which holds the dm-verity hash that verifies
|
||||
`/usr`.
|
||||
- **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.
|
||||
There is no recovery key: if the TPM is lost, reinstall.
|
||||
- **Jobs in containers:** each job runs in its own privileged container on
|
||||
root's podman. Jobs with `runs-on: linux` run in our job image: Fedora with
|
||||
git, Node.js 26, podman and dnf, built with the OS and shipped in `/usr`.
|
||||
Privileged jobs can build OS and container 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
|
||||
before it reboots into an update, and a bad update rolls back by itself.
|
||||
|
||||
## Install
|
||||
|
||||
Download [the disk image](https://git.plabble.org/api/packages/Job79/generic/runneros/latest/runneros.qcow2),
|
||||
resize it to the disk size you want and boot it with UEFI and a TPM. At first
|
||||
boot, the screen asks for a timezone and a root password. Then it asks how many jobs to run at once, the Gitea URL and a
|
||||
registration token from Gitea's runner settings. It registers under the
|
||||
hostname, `runneros-` and four hex digits, and starts.
|
||||
|
||||
To change the number of parallel jobs later, run `systemctl edit
|
||||
gitea-runner` and set `Environment=CAPACITY=<jobs>` under `[Service]`.
|
||||
|
||||
To start over, run `systemctl start factory-reset.target` as root. It reboots,
|
||||
the firmware asks to clear the TPM (press F12), and it wipes the root partition
|
||||
(`/etc` and `/var`). The VM then sets itself up as at first boot.
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
mkosi -f genkey # This replaces mkosi.crt for local tests. Don't commit it.
|
||||
mkosi build
|
||||
```
|
||||
|
||||
`mkosi.output/` then holds the disk image (`runneros_<version>.raw`) and the
|
||||
UKI and /usr partitions that make up an update. To boot a test VM, see
|
||||
[AGENTS.md](AGENTS.md#testing).
|
||||
@@ -1,18 +0,0 @@
|
||||
# git-runner job image
|
||||
#
|
||||
# The default image for jobs (`runs-on: linux`), built and pushed by the job
|
||||
# workflow. It is kept small: just what common actions need. Jobs run their
|
||||
# own podman (`docker` is an alias); the runner gives it the shared base
|
||||
# images, see mkosi.extra/usr/lib/gitea-runner/config.yaml.
|
||||
#
|
||||
# Includes:
|
||||
# - git-core openssh-clients checkout
|
||||
# - nodejs26 JavaScript actions
|
||||
# - podman skopeo images
|
||||
# - tar gzip zstd findutils cache and artifact actions
|
||||
FROM quay.io/fedora/fedora-minimal:45
|
||||
|
||||
RUN dnf -y install --setopt=install_weak_deps=False \
|
||||
git-core nodejs26 podman skopeo tar gzip zstd findutils openssh-clients \
|
||||
&& dnf clean all \
|
||||
&& ln -s podman /usr/bin/docker
|
||||
+110
-43
@@ -1,62 +1,129 @@
|
||||
# git-runner: a Fedora VM image that runs the Gitea Actions runner, built with mkosi.
|
||||
# mkosi.extra/ is copied to /, mkosi.repart/ defines the disk, mkosi.prepare adds the runner.
|
||||
# mkosi.conf builds runneros, a Fedora VM image that runs a Gitea Actions
|
||||
# runner. The image holds a read-only /usr. The root filesystem, which holds
|
||||
# the state, is made at first boot.
|
||||
#
|
||||
# The other parts of the build:
|
||||
# - mkosi.extra/ is copied to /.
|
||||
# - mkosi.repart/ defines the disk image: the ESP and the /usr partitions.
|
||||
# - mkosi.extra/usr/lib/repart.d/ makes the root partition at first boot.
|
||||
# - 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
|
||||
Release=45
|
||||
|
||||
[Output]
|
||||
Format=disk
|
||||
ImageId=git-runner
|
||||
# Output writes runneros_<version>.* to mkosi.output/. The UKI and /usr
|
||||
# partitions are split into the files of an update.
|
||||
ImageId=runneros
|
||||
OutputDirectory=mkosi.output
|
||||
# The UKI and /usr partitions are published as updates (systemd-sysupdate).
|
||||
SplitArtifacts=uki,partitions
|
||||
ManifestFormat=json
|
||||
|
||||
[Content]
|
||||
Bootable=yes
|
||||
Bootloader=systemd-boot
|
||||
# - kernel-core no drivers or firmware beyond what VMs need
|
||||
# - systemd-container systemd-pull, which systemd-sysupdate downloads with
|
||||
# - systemd-boot-unsigned the bootloader
|
||||
# - util-linux, shadow-utils console login and the first-boot setup
|
||||
# - podman, git-core the runner's jobs; git fetches actions
|
||||
# - nftables-services the firewall
|
||||
# - zram-generator-defaults compressed swap in RAM
|
||||
Packages=
|
||||
kernel-core
|
||||
systemd
|
||||
dbus-broker
|
||||
systemd-udev
|
||||
systemd-networkd
|
||||
systemd-resolved
|
||||
systemd-container
|
||||
systemd-boot-unsigned
|
||||
util-linux
|
||||
shadow-utils
|
||||
podman
|
||||
git-core
|
||||
nftables-services
|
||||
zram-generator-defaults
|
||||
# Content sets what goes into the image:
|
||||
# - 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_<version>.efi, which
|
||||
# matches the MatchPattern= of mkosi.extra/usr/lib/sysupdate.d/20-uki.transfer.
|
||||
# - KernelCommandLine:
|
||||
# - rw has the initrd mount the root filesystem writable. It finds it by its
|
||||
# partition type (mkosi.extra/usr/lib/repart.d/50-root.conf).
|
||||
# - The hostname is runneros- and four hex digits of the machine ID, also
|
||||
# the name the runner registers with. Unlike /etc/hostname, which only
|
||||
# exists once tmpfiles links it, the command line has it from the first
|
||||
# boot on.
|
||||
# - The image policy only accepts an encrypted root filesystem (or none, at
|
||||
# first boot) and a verity-checked /usr. Otherwise someone with the disk
|
||||
# could swap in a plain root filesystem. Our UKI would boot it, and their
|
||||
# code could unseal the key of the real one.
|
||||
# - The root btrfs keeps one copy of its metadata instead of two (DUP,
|
||||
# mkfs.btrfs's default). On a VM disk a second copy adds little.
|
||||
# - The mount rate limit is raised from 5, which holds back mounts at boot
|
||||
# and delays / and /usr by up to a second each.
|
||||
# - KernelInitrdModules are what the initrd needs to find the disks of a VM,
|
||||
# mount /usr and unlock the root filesystem. The kernel has virtio_blk,
|
||||
# sd_mod, the TPM drivers and btrfs built in.
|
||||
# - KernelModules keeps all modules but the hardware drivers, then adds back
|
||||
# the drivers a VM needs (disks, network, screen) and those of podman's
|
||||
# networks (veth, tun). The last matching line wins. Keyboard, USB and a
|
||||
# basic screen are built into the kernel.
|
||||
# - RemoveFiles drops System.map, which is only for debugging the kernel, and
|
||||
# the udev hwdb, which holds hardware names and quirks a VM doesn't need.
|
||||
# Without hwdb.d, systemd-hwdb-update can't build it again at boot.
|
||||
WithDocs=no
|
||||
Locale=C.UTF-8
|
||||
# The UKI's file name in the ESP, as systemd-sysupdate names the ones it installs.
|
||||
Packages=
|
||||
kernel-core # Unlike kernel, this has no extra drivers.
|
||||
systemd # The init and service manager is PID 1.
|
||||
dbus-broker # D-Bus serves systemd and podman.
|
||||
systemd-udev # Udev, sysupdate, repart, cryptsetup are here.
|
||||
systemd-networkd # DHCP runs on every network card.
|
||||
systemd-resolved # DNS names are resolved here.
|
||||
systemd-container # Sysupdate needs its systemd-pull and gnupg2.
|
||||
systemd-boot-unsigned # mkosi signs this boot loader.
|
||||
util-linux # The console login needs its login.
|
||||
systemd-pam # Logins get a session.
|
||||
zram-generator-defaults # Swap is compressed in RAM.
|
||||
podman # The runner runs its jobs in containers.
|
||||
git-core # The runner fetches the actions jobs use.
|
||||
curl
|
||||
procps-ng
|
||||
iproute
|
||||
ExtraTrees=%O/job:/usr/lib/runneros/job
|
||||
UnifiedKernelImageFormat=%i_%v
|
||||
KernelCommandLine=
|
||||
rw
|
||||
console=tty0
|
||||
console=ttyS0,115200n8
|
||||
quiet
|
||||
systemd.firstboot=no
|
||||
slab_nomerge
|
||||
init_on_alloc=1
|
||||
randomize_kstack_offset=on
|
||||
page_alloc.shuffle=1
|
||||
# Kernel modules in the initrd: only what finds and mounts the disks of a VM.
|
||||
rw
|
||||
systemd.hostname=runneros-????
|
||||
systemd.image_policy=root=encrypted+absent:usr=verity:esp=unprotected
|
||||
systemd.setenv=SYSTEMD_REPART_MKFS_OPTIONS_BTRFS=--metadata=single
|
||||
SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=50
|
||||
KernelInitrdModules=
|
||||
virtio_blk
|
||||
virtio_scsi
|
||||
sd_mod
|
||||
nvme
|
||||
dm-verity
|
||||
dm-crypt
|
||||
erofs
|
||||
ext4
|
||||
KernelModules=
|
||||
/*
|
||||
-/drivers/*
|
||||
/drivers/virtio/*
|
||||
/drivers/block/*
|
||||
/drivers/md/*
|
||||
nvme
|
||||
virtio_scsi
|
||||
virtio_net
|
||||
qemu_fw_cfg
|
||||
bochs
|
||||
virtio-gpu
|
||||
veth
|
||||
tun
|
||||
RemoveFiles=
|
||||
/usr/lib/modules/*/System.map
|
||||
/usr/lib/udev/hwdb.bin
|
||||
/usr/lib/udev/hwdb.d
|
||||
|
||||
[Validation]
|
||||
# Validation signs the boot chain with mkosi.key, so the TPM unlocks the root
|
||||
# filesystem only for our UKIs.
|
||||
SecureBoot=yes
|
||||
SignExpectedPcr=yes
|
||||
|
||||
[Runtime]
|
||||
# Runtime sets up the test VM of mkosi vm. Each run boots a fresh copy, with
|
||||
# root password root and no first boot questions. It has enough memory and
|
||||
# disk to build this image in a job.
|
||||
Ephemeral=yes
|
||||
CPUs=4
|
||||
RAM=6G
|
||||
RuntimeSize=40G
|
||||
Credentials=passwd.plaintext-password.root=root
|
||||
KernelCommandLineExtra=systemd.firstboot=no
|
||||
@@ -1,18 +1,18 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC3DCCAcSgAwIBAgIUJf6brtTrJfRyg89YFBAFKNkMhZYwDQYJKoZIhvcNAQEL
|
||||
BQAwJzElMCMGA1UEAwwcZ2l0LXJ1bm5lci1ta29zaSBTZWN1cmUgQm9vdDAgFw0y
|
||||
NjExMTIyMTMyMzdaGA8yMTI2MTAxOTIxMzIzN1owJzElMCMGA1UEAwwcZ2l0LXJ1
|
||||
bm5lci1ta29zaSBTZWN1cmUgQm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
|
||||
AQoCggEBAObV42lyR2vWBjln4wLo0+l3BZY5r9ej6N19H4cGyrGyBlAmM+U8LzAG
|
||||
VQYnxF+vXPfXqJtvWBl1o/10Qww+u6MD4dKrWqI00YMNEyJDTneCaobshkJf1nbK
|
||||
iAZyul/nrfR8AErI52fjKrT89PdskpBsQqMeOM3Xu/q585a2aMOLQBn2TRyqq95N
|
||||
KPEYfMiZRJ5QiIrWU0QdALvrxB07CZ4P0EW9chs8vyjysPM3EwiQiAny4KnAVgKF
|
||||
pot8rbUcQz9ias92VlqMdTpPks7HaXyDt1eREV3yZoGPaB3kKj1DIUqHWB3B6kuk
|
||||
cfmRrU34EGHfRF97Sf26BmqnE2HLIpMCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA
|
||||
ZhNuMz1p+oc0ClttIQbo4sdarpdmgr5Abvdh8C9vwVQrJLMynEQL4d4IAaSJ+SKz
|
||||
og6gmNKYwmX6CusK2/vFQnobWYQphe+tiC6qdMcwMuy2R/Shp6PWTQjvsU1R7R42
|
||||
Y9Uba3yFwibqRPGjFjUEh39d0MSZ5pKFuC82F746QntLZnHQQVWdnVnyTaA25JH2
|
||||
F0l8CqH3iz6GHz65Q0zMx7EOVyKfAcM7t4KPH/McV8FSBCkOm9UhxGQcpnxQc8iH
|
||||
JvKuI+Vys4I1xtFrCULFhR2Yo2984zafcCXlFv4Xib/h0Mpu1s8f1AcyrEsITonl
|
||||
AOTjyyxDX8zSnTrW3phSjA==
|
||||
MIICzjCCAbagAwIBAgIUVszVwCQVaOBS3MyL9TUA4lMaeHowDQYJKoZIhvcNAQEL
|
||||
BQAwITEfMB0GA1UEAwwWZ2l0LXJ1bm5lciBTZWN1cmUgQm9vdDAeFw0yNjExMTQy
|
||||
MTE1MjhaFw0zNjExMTEyMTE1MjhaMCExHzAdBgNVBAMMFmdpdC1ydW5uZXIgU2Vj
|
||||
dXJlIEJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDO1KaKLK6e
|
||||
phfFvGyceuWGkJvnehJ5634rhty4gsyJlFVZSdZvDTU5iU6okjwtnYShEgEH02jX
|
||||
Xgj7Y76iBuetAFjx1ISAdJNxdPHHO7uazLidMQ2gaVsSXayTPgwNmKoJ2xMmkoyQ
|
||||
SO1vqTymWlVGJptgFIOivUbFBhovxSqeAC2kFplK11/3mQxl1Oxd7Lrh9BwBZbqU
|
||||
E9Rd2eQUo8g9JjBA9nR7ogxa4wyP1mpMyvmJ2NbcuMunpKQC66eW5RNH3ERgJi36
|
||||
fPiuT/ou+gjpYZo1HW6c59nx9XFO6epCcDWRV2xfcB/iFaDIVuJafDWvyeB1RFD+
|
||||
CguGyHI7VFSTAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAI84Ucm8m45nRFPf6ffb
|
||||
vlfamcO+HIhobyPmafwEGLv6HWjHC9I9XulmEOHz9PePEI2TX0K9I883IGvmoyEA
|
||||
AMI1f9kskm2Xg7Xk/OLXmqHDGDbJFNaS8e79ImBqu9bBWe4rOa6naeH7JiVjTh5Y
|
||||
2APyP+o+DKrXuCjcQtZc1PkuQPrElNmqKduhfL4acIPR0N7kJ58FwpuE9Zh8C0p1
|
||||
NSb7x38Dxxwid4zWDbSuIeIi0FfCFHC8olvzfDQlNst5VQeE921KcK8YKREIgn0H
|
||||
2GLtzpczUGq8u6Pen7R8qSjLZ0GlVXfMlW1EthoYnlP1n4oxg6xfPn2J5SyP2EGi
|
||||
Iis=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,29 @@
|
||||
# config.yaml configures the runner (gitea-runner.service). It lists only what
|
||||
# differs from the defaults, which `gitea-runner config generate` prints.
|
||||
#
|
||||
# The image links it into /etc read-only
|
||||
# (mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf). To change it on one
|
||||
# machine, replace the link with a copy. Updates then no longer change it.
|
||||
runner:
|
||||
# file is where `gitea-runner register` keeps the registration, wherever it
|
||||
# runs. gitea-runner.path starts the runner once it is there.
|
||||
file: /var/lib/gitea-runner/.runner
|
||||
# capacity is the number of parallel jobs, set by gitea-runner.service.
|
||||
capacity: ${CAPACITY}
|
||||
# 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://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.
|
||||
privileged: true
|
||||
# docker_host "-" keeps podman's socket out of the jobs.
|
||||
docker_host: "-"
|
||||
# options gives each job volumes for /var/tmp and /var/lib/containers. On
|
||||
# the container's overlayfs, mkosi loses the xattrs of the files it copies,
|
||||
# such as file capabilities, and podman can't keep its storage.
|
||||
options: --volume /var/tmp --volume /var/lib/containers
|
||||
@@ -1,32 +0,0 @@
|
||||
# The runner's configuration (gitea-runner.service).
|
||||
# Every option: `gitea-runner config generate`.
|
||||
runner:
|
||||
# Parallel jobs, asked at first boot (stored in /etc/gitea-runner/runner.env).
|
||||
capacity: ${GITEA_RUNNER_CAPACITY}
|
||||
# On stop (before an update reboot), take no new jobs and give running ones this long to finish.
|
||||
shutdown_timeout: 30m
|
||||
envs:
|
||||
# podman in jobs: the job's own storage plus the shared base images (see volumes below).
|
||||
CONTAINERS_STORAGE_CONF: /usr/lib/gitea-runner/job/storage.conf
|
||||
labels:
|
||||
# Our job image (job/Containerfile): git, node, skopeo and podman.
|
||||
- "linux:docker://git.plabble.org/job79/git-runner-mkosi-job:latest"
|
||||
# Plain Fedora; our own build workflows use it, so a broken job image can't block its own fix.
|
||||
- "fedora:docker://quay.io/fedora/fedora:45"
|
||||
container:
|
||||
# Jobs build OS images, which needs root: they run privileged on root's podman.
|
||||
privileged: true
|
||||
# podman can't keep its storage, or build contexts, on the job's own overlay root.
|
||||
options: --volume /var/lib/containers --volume /var/tmp
|
||||
# Jobs run their own podman, never the runner's.
|
||||
docker_host: "-"
|
||||
volumes:
|
||||
# Base images, pulled at boot by gitea-runner-images.service; podman in jobs uses them read-only.
|
||||
- /var/lib/containers/base-images:/var/lib/base-images:ro
|
||||
# podman storage settings for jobs (see the file).
|
||||
- /usr/lib/gitea-runner/job:/usr/lib/gitea-runner/job:ro
|
||||
force_pull: true
|
||||
cache:
|
||||
# Jobs reach the cache on the host through their bridge; the firewall allows this port.
|
||||
host: host.containers.internal
|
||||
port: 8088
|
||||
@@ -1,22 +0,0 @@
|
||||
# Firewall: drop all incoming traffic except replies, loopback, ICMP and DHCPv6.
|
||||
# Loaded by nftables.service. Jobs live on podman bridges (podman*): they may reach the
|
||||
# internet, DNS on their bridge, and the runner's cache server (config.yaml), nothing else here.
|
||||
destroy table inet firewall
|
||||
table inet firewall {
|
||||
chain input {
|
||||
type filter hook input priority filter; policy drop;
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
iif lo accept
|
||||
meta l4proto { icmp, ipv6-icmp } accept
|
||||
ip6 saddr fe80::/10 udp dport 546 accept
|
||||
iifname "podman*" meta l4proto { tcp, udp } th dport 53 accept
|
||||
iifname "podman*" tcp dport 8088 accept
|
||||
}
|
||||
chain forward {
|
||||
type filter hook forward priority filter; policy drop;
|
||||
ct state established,related accept
|
||||
ct state invalid drop
|
||||
iifname "podman*" accept
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
# podman storage in jobs (CONTAINERS_STORAGE_CONF). The job's own images go to the /var/lib/containers
|
||||
# volume; the base images the host pulls at boot are shared read-only, so jobs don't download them.
|
||||
[storage]
|
||||
driver = "overlay"
|
||||
graphroot = "/var/lib/containers/storage"
|
||||
runroot = "/run/containers/storage"
|
||||
|
||||
[storage.options]
|
||||
additionalimagestores = ["/var/lib/base-images"]
|
||||
@@ -1,4 +1,10 @@
|
||||
# Grow the root partition to fill the disk at boot (systemd-repart); systemd-growfs then grows
|
||||
# its filesystem (GrowFileSystem= in mkosi.repart/30-root.conf).
|
||||
# 50-root.conf makes the root filesystem at first boot, in the free space after
|
||||
# /usr, and grows it with the disk. It holds all state: /etc and /var.
|
||||
#
|
||||
# The key is in the TPM, sealed to the signed PCR 11 policy of our UKIs
|
||||
# (SignExpectedPcr= in mkosi.conf).
|
||||
[Partition]
|
||||
Type=root
|
||||
Format=btrfs
|
||||
Encrypt=tpm2
|
||||
FactoryReset=yes
|
||||
@@ -1,31 +0,0 @@
|
||||
# Hardening, mostly the KSPP recommendations that Talos also sets by default.
|
||||
# Left out on purpose: user.max_user_namespaces=0 breaks podman in jobs, and kernel.modules_disabled=1
|
||||
# breaks loading the network modules podman needs.
|
||||
|
||||
# Hide kernel addresses in /proc and logs, even from root; they help exploits bypass KASLR.
|
||||
kernel.kptr_restrict = 2
|
||||
# Only root may read the kernel log (it leaks addresses and hardware details).
|
||||
kernel.dmesg_restrict = 1
|
||||
# No perf events for non-root users. Upstream kernels treat 3 like 2 (the strictest they know).
|
||||
kernel.perf_event_paranoid = 3
|
||||
# Harden the BPF JIT against JIT spraying, for every user. Small cost when BPF is used.
|
||||
net.core.bpf_jit_harden = 2
|
||||
# No BPF for non-root users, and it can't be switched back on at runtime (Fedora's default 2 can).
|
||||
kernel.unprivileged_bpf_disabled = 1
|
||||
# No kexec: nobody can boot another kernel without going through Secure Boot.
|
||||
kernel.kexec_load_disabled = 1
|
||||
# No core dumps of setuid programs; they can contain secrets.
|
||||
fs.suid_dumpable = 0
|
||||
# Don't load TTY line disciplines on demand; old ones have had exploitable bugs.
|
||||
dev.tty.ldisc_autoload = 0
|
||||
# userfaultfd only for root; it is used to make kernel race exploits reliable.
|
||||
vm.unprivileged_userfaultfd = 0
|
||||
# Don't open FIFOs and regular files owned by someone else in sticky directories like /tmp.
|
||||
fs.protected_fifos = 2
|
||||
fs.protected_regular = 2
|
||||
# A process may only ptrace its own descendants (gdb ./prog works, gdb -p <other pid> doesn't).
|
||||
kernel.yama.ptrace_scope = 1
|
||||
|
||||
# Performance: Fedora allows 128 inotify instances per user. Many containers (file watchers,
|
||||
# systemd inside containers) run out of those; 8192 is common on Kubernetes nodes.
|
||||
fs.inotify.max_user_instances = 8192
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
# DHCP on the real network cards. Kind=!* skips virtual links like the veths of podman's bridges,
|
||||
# which netavark manages.
|
||||
# 80-dhcp.network turns on DHCP on the real network cards. Kind=!* skips
|
||||
# virtual links such as those of containers.
|
||||
[Match]
|
||||
Type=ether
|
||||
Kind=!*
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# Services enabled in the image (mkosi runs systemctl preset-all).
|
||||
enable systemd-networkd.service
|
||||
enable systemd-resolved.service
|
||||
enable nftables.service
|
||||
enable podman.socket
|
||||
enable gitea-runner-setup.service
|
||||
enable gitea-runner.service
|
||||
enable systemd-sysupdate-update.timer
|
||||
enable systemd-sysupdate-reboot.timer
|
||||
@@ -0,0 +1,26 @@
|
||||
# 50-runneros.preset enables the services of the image. PID 1 applies it at
|
||||
# first boot, so a change reaches existing machines only after a factory reset.
|
||||
# It sorts before Fedora's presets, so it wins where they disagree.
|
||||
|
||||
# systemd-networkd is disabled by Fedora, which uses NetworkManager.
|
||||
enable systemd-networkd.service
|
||||
|
||||
# gitea-runner-setup.service registers the runner, and gitea-runner.path then
|
||||
# starts it.
|
||||
enable gitea-runner-setup.service
|
||||
enable gitea-runner.path
|
||||
disable gitea-runner.service
|
||||
|
||||
# getty@.service is the login on the screen, which Fedora disables.
|
||||
enable getty@.service
|
||||
enable systemd-sysupdate-update.timer
|
||||
enable systemd-sysupdate-reboot.timer
|
||||
|
||||
# authselect-apply-changes fails, because /etc/authselect is on read-only /usr.
|
||||
disable authselect-apply-changes.service
|
||||
|
||||
# systemd-homed, systemd-userdbd and systemd-nsresourced are unused here.
|
||||
disable systemd-homed.service
|
||||
disable systemd-homed-activate.service
|
||||
disable systemd-userdbd.socket
|
||||
disable systemd-nsresourced.socket
|
||||
@@ -1,17 +0,0 @@
|
||||
# Pulls the base images that jobs share read-only (see /usr/lib/gitea-runner/config.yaml) before the
|
||||
# runner starts, so no job uses them while they change. Hosts reboot to update, so this runs about
|
||||
# as often as there are updates.
|
||||
[Unit]
|
||||
Description=Base images for Gitea Actions jobs
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
Before=gitea-runner.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Environment=IMAGES=/var/lib/containers/base-images
|
||||
# Without network the runner still starts, with the images it has.
|
||||
ExecStart=-/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images pull -q --policy newer \
|
||||
quay.io/fedora/fedora:45 quay.io/fedora/fedora-minimal:45
|
||||
ExecStart=/usr/bin/podman --root ${IMAGES} --runroot /run/containers/base-images image prune -f
|
||||
TimeoutStartSec=30min
|
||||
@@ -1,17 +1,21 @@
|
||||
# First boot: asks for the root password and the runner's registration on the console (tty1).
|
||||
# gitea-runner-setup.service runs /usr/libexec/gitea-runner-setup on the
|
||||
# console until the runner is registered, after systemd-firstboot has asked
|
||||
# its questions there. Logins wait for it, as for systemd-firstboot, so no
|
||||
# getty reads the same console.
|
||||
[Unit]
|
||||
Description=Gitea runner first-boot setup
|
||||
ConditionPathExists=!/etc/gitea-runner/runner.env
|
||||
Before=getty@tty1.service kmsconvt@tty1.service
|
||||
Description=Gitea runner setup
|
||||
ConditionPathExists=!/var/lib/gitea-runner/.runner
|
||||
Wants=network-online.target
|
||||
After=systemd-firstboot.service network-online.target
|
||||
Before=systemd-user-sessions.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
# HOME is where gitea-runner keeps its cache, as in gitea-runner.service.
|
||||
Environment=HOME=/var/lib/gitea-runner
|
||||
ExecStart=/usr/libexec/gitea-runner-setup
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
TTYPath=/dev/tty1
|
||||
TTYReset=yes
|
||||
TTYVHangup=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,10 @@
|
||||
# gitea-runner.path starts the runner once it is registered, so a new machine
|
||||
# waits for gitea-runner-setup.service.
|
||||
[Unit]
|
||||
Description=Start the Gitea runner once registered
|
||||
|
||||
[Path]
|
||||
PathExists=/var/lib/gitea-runner/.runner
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,24 +1,28 @@
|
||||
# The Gitea Actions runner. Registers itself on its first start.
|
||||
# gitea-runner.service runs the Gitea Actions runner, which runs each job in a
|
||||
# container on root's podman. gitea-runner.path starts it once it is
|
||||
# registered. It runs as root: whoever has podman's socket is root anyway.
|
||||
#
|
||||
# TimeoutStopSec is a bit longer than runner.shutdown_timeout in
|
||||
# /etc/gitea-runner/config.yaml, so running jobs can finish on stop.
|
||||
[Unit]
|
||||
Description=Gitea Actions runner
|
||||
Wants=network-online.target gitea-runner-images.service
|
||||
After=network-online.target podman.socket gitea-runner-images.service
|
||||
Wants=network-online.target
|
||||
After=network-online.target podman.socket
|
||||
Requires=podman.socket
|
||||
|
||||
[Service]
|
||||
# The runner drives root's podman (podman.socket.d gives this user the socket). The jobs it starts
|
||||
# never get the socket (see config.yaml).
|
||||
User=gitea-runner
|
||||
WorkingDirectory=/var/lib/gitea-runner
|
||||
EnvironmentFile=/etc/gitea-runner/runner.env
|
||||
# CAPACITY is the number of parallel jobs. gitea-runner-setup writes a drop-in
|
||||
# that overrides it, which `systemctl edit gitea-runner` changes.
|
||||
Environment=CAPACITY=1
|
||||
# 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
|
||||
# Register once; the result is kept in .runner.
|
||||
ExecStartPre=/bin/sh -c '[ -f .runner ] || exec gitea-runner register --no-interactive --config /usr/lib/gitea-runner/config.yaml --instance "$GITEA_INSTANCE_URL"'
|
||||
ExecStart=/usr/bin/gitea-runner daemon --config /usr/lib/gitea-runner/config.yaml
|
||||
# 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
|
||||
# A bit longer than runner.shutdown_timeout, so running jobs can finish on stop.
|
||||
TimeoutStopSec=35min
|
||||
RestartSec=10s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
TimeoutStopSec=65min
|
||||
@@ -1,6 +0,0 @@
|
||||
# Load our firewall (/usr/lib/gitea-runner/firewall.nft) instead of /etc/sysconfig/nftables.conf.
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/sbin/nft -f /usr/lib/gitea-runner/firewall.nft
|
||||
ExecReload=
|
||||
ExecReload=/usr/sbin/nft -f /usr/lib/gitea-runner/firewall.nft
|
||||
@@ -1,4 +0,0 @@
|
||||
# The runner may use root's podman. Jobs never get this socket.
|
||||
[Socket]
|
||||
SocketGroup=gitea-runner
|
||||
SocketMode=0660
|
||||
@@ -1,5 +1,6 @@
|
||||
# Daily at about 04:10, reboot into a downloaded update. Stop the runner first: it takes no new
|
||||
# jobs and lets running ones finish (runner.shutdown_timeout).
|
||||
# drain.conf stops the runner before an update reboots the machine, so running
|
||||
# jobs can finish first (TimeoutStopSec= of gitea-runner.service). A plain
|
||||
# reboot would stop the job containers at the same time as the runner.
|
||||
[Service]
|
||||
ExecStartPre=/bin/sh -c '/usr/lib/systemd/systemd-sysupdate pending || exit 0; systemctl stop gitea-runner'
|
||||
TimeoutStartSec=40min
|
||||
ExecStartPre=/bin/sh -c '/usr/lib/systemd/systemd-sysupdate pending || exit 0; systemctl stop gitea-runner.service'
|
||||
TimeoutStartSec=70min
|
||||
@@ -1,18 +1,20 @@
|
||||
# Updates /usr: writes the next version to the unused /usr partition.
|
||||
# 10-usr.transfer writes the next version of /usr to the inactive /usr
|
||||
# partition.
|
||||
#
|
||||
# systemd-sysupdate requires SHA256SUMS.gpg to be signed by a key in
|
||||
# /usr/lib/systemd/import-pubring.pgp, and SHA256SUMS checks each download.
|
||||
[Transfer]
|
||||
ProtectVersion=%A
|
||||
# Not signed: the Secure Boot signed UKI pins the hash of /usr (usrhash=).
|
||||
Verify=no
|
||||
|
||||
[Source]
|
||||
Type=url-file
|
||||
Path=https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
|
||||
MatchPattern=git-runner_@v.usr-%a.raw.zst
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/runneros/latest/
|
||||
MatchPattern=runneros_@v.usr-%a.@u.raw.zst
|
||||
|
||||
[Target]
|
||||
Type=partition
|
||||
Path=auto
|
||||
MatchPattern=git-runner_@v
|
||||
MatchPattern=runneros_@v
|
||||
MatchPartitionType=usr
|
||||
PartitionFlags=0
|
||||
ReadOnly=1
|
||||
@@ -1,17 +1,17 @@
|
||||
# Updates the dm-verity hashes of /usr, next to 10-usr.transfer.
|
||||
# 11-usr-verity.transfer writes the dm-verity hashes that go with
|
||||
# 10-usr.transfer, which explains how downloads are checked.
|
||||
[Transfer]
|
||||
ProtectVersion=%A
|
||||
Verify=no
|
||||
|
||||
[Source]
|
||||
Type=url-file
|
||||
Path=https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
|
||||
MatchPattern=git-runner_@v.usr-%a-verity.raw.zst
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/runneros/latest/
|
||||
MatchPattern=runneros_@v.usr-%a-verity.@u.raw.zst
|
||||
|
||||
[Target]
|
||||
Type=partition
|
||||
Path=auto
|
||||
MatchPattern=git-runner_@v_verity
|
||||
MatchPattern=runneros_@v_verity
|
||||
MatchPartitionType=usr-verity
|
||||
PartitionFlags=0
|
||||
ReadOnly=1
|
||||
@@ -1,20 +1,23 @@
|
||||
# Installs the next UKI, which systemd-boot boots by default. If it fails to boot 3 times,
|
||||
# systemd-boot falls back to the previous one.
|
||||
# 20-uki.transfer installs the next UKI, which systemd-boot then boots by
|
||||
# default. For how downloads are checked, see 10-usr.transfer.
|
||||
#
|
||||
# The new UKI gets three tries (boot counting: the +@l-@d in its name).
|
||||
# systemd-bless-boot marks it good once a boot reaches boot-complete.target.
|
||||
# If no boot does, systemd-boot goes back to the previous UKI, and with it to
|
||||
# the previous /usr partition, because each UKI holds its usr hash.
|
||||
[Transfer]
|
||||
ProtectVersion=%A
|
||||
Verify=no
|
||||
|
||||
[Source]
|
||||
Type=url-file
|
||||
Path=https://git.plabble.org/api/packages/job79/generic/git-runner-mkosi/latest/
|
||||
MatchPattern=git-runner_@v.efi
|
||||
Path=https://git.plabble.org/api/packages/Job79/generic/runneros/latest/
|
||||
MatchPattern=runneros_@v.efi
|
||||
|
||||
[Target]
|
||||
Type=regular-file
|
||||
Path=/EFI/Linux
|
||||
PathRelativeTo=boot
|
||||
MatchPattern=git-runner_@v+@l-@d.efi git-runner_@v+@l.efi git-runner_@v.efi
|
||||
Mode=0444
|
||||
MatchPattern=runneros_@v+@l-@d.efi runneros_@v+@l.efi runneros_@v.efi
|
||||
TriesLeft=3
|
||||
TriesDone=0
|
||||
InstancesMax=2
|
||||
@@ -1,2 +0,0 @@
|
||||
# The runner's user.
|
||||
u gitea-runner - "Gitea Actions runner" /var/lib/gitea-runner
|
||||
@@ -0,0 +1,28 @@
|
||||
# factory-etc.conf links what the image needs from /usr/share/factory/etc
|
||||
# (mkosi.finalize) into the empty /etc at boot, so updates to /usr take effect
|
||||
# in /etc too. The rest of the factory is unused package config. /etc itself
|
||||
# holds what the machine writes: passwd, shadow, group, machine-id, ld.so.cache,
|
||||
# /etc/systemd and the networks of podman (/etc/containers/networks). Podman
|
||||
# reads its own config from /usr/share/containers. systemd's own etc.conf sets
|
||||
# up os-release, nsswitch.conf and pam.d.
|
||||
#
|
||||
# /etc/systemd is filled from the presets at first boot, by PID 1.
|
||||
|
||||
# gitea-runner holds the config of the runner.
|
||||
L /etc/gitea-runner
|
||||
|
||||
# authselect holds the PAM files that /etc/pam.d links to.
|
||||
L /etc/authselect
|
||||
L /etc/security
|
||||
L /etc/environment
|
||||
L /etc/shells
|
||||
|
||||
# pki and ssl hold the CA certificates, and crypto-policies the TLS settings.
|
||||
L /etc/pki
|
||||
L /etc/ssl
|
||||
L /etc/crypto-policies
|
||||
L /etc/bashrc
|
||||
L /etc/profile
|
||||
L /etc/profile.d
|
||||
L /etc/protocols
|
||||
L /etc/services
|
||||
@@ -1,9 +1,7 @@
|
||||
# The runner's directories, and a clean container storage on every boot.
|
||||
# Home directory; holds the registration (.runner) and the actions cache.
|
||||
d /var/lib/gitea-runner 0700 gitea-runner gitea-runner -
|
||||
# podman's own line makes this 0700; the runner needs to reach podman.sock inside (podman.socket.d).
|
||||
# This file sorts before podman.conf, so its line wins.
|
||||
D! /run/podman 0750 root gitea-runner -
|
||||
# Wipe all job containers, volumes and images on every boot. The shared base images
|
||||
# (/var/lib/containers/base-images) stay; gitea-runner-images.service updates them.
|
||||
# gitea-runner.conf makes the state directory of the runner, which holds its
|
||||
# registration (/etc/gitea-runner/config.yaml).
|
||||
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. gitea-runner.service loads the job image again.
|
||||
R /var/lib/containers/storage
|
||||
@@ -1,25 +1,24 @@
|
||||
#!/bin/bash
|
||||
# First boot: ask for the root password and the runner's registration.
|
||||
# gitea-runner-setup asks on the console for the number of parallel jobs and
|
||||
# the runner's registration, and registers the runner. gitea-runner.path then
|
||||
# starts it. gitea-runner-setup.service runs it until the runner is registered.
|
||||
#
|
||||
# The capacity goes to a drop-in of gitea-runner.service, which passes it to
|
||||
# /etc/gitea-runner/config.yaml as CAPACITY. It is written first, because the
|
||||
# runner starts as soon as it is registered.
|
||||
set -euo pipefail
|
||||
echo "== Gitea runner setup =="
|
||||
|
||||
while :; do
|
||||
read -rsp "Root password: " pw; echo
|
||||
read -rsp "Again: " pw2; echo
|
||||
[[ -n $pw && $pw == "$pw2" ]] && break
|
||||
echo "Passwords do not match, try again."
|
||||
done
|
||||
echo "root:$pw" | chpasswd
|
||||
|
||||
read -rp "Hostname (also the runner name): " name
|
||||
read -rp "Gitea URL (e.g. https://gitea.example.com): " url
|
||||
read -rp "Runner registration token: " token
|
||||
read -rp "Parallel jobs [1]: " capacity
|
||||
[[ $capacity =~ ^[1-9][0-9]*$ ]] || capacity=1
|
||||
hostnamectl hostname "$name"
|
||||
install -D -m 0640 -g gitea-runner /dev/stdin /etc/gitea-runner/runner.env <<ENV
|
||||
GITEA_INSTANCE_URL=$url
|
||||
GITEA_RUNNER_REGISTRATION_TOKEN=$token
|
||||
GITEA_RUNNER_CAPACITY=$capacity
|
||||
ENV
|
||||
echo "Done. The runner registers itself within a few seconds."
|
||||
mkdir -p /etc/systemd/system/gitea-runner.service.d
|
||||
printf '[Service]\nEnvironment=CAPACITY=%s\n' "$capacity" \
|
||||
> /etc/systemd/system/gitea-runner.service.d/capacity.conf
|
||||
systemctl daemon-reload
|
||||
|
||||
export CAPACITY=$capacity
|
||||
until [[ -f /var/lib/gitea-runner/.runner ]]; do
|
||||
read -rp "Gitea URL: " url
|
||||
read -rp "Registration token: " token
|
||||
gitea-runner -c /etc/gitea-runner/config.yaml register --no-interactive \
|
||||
--instance "$url" --token "$token" || echo "Try again."
|
||||
done
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
# mkosi.finalize keeps the /etc that the packages and mkosi.extra/etc made in
|
||||
# /usr/share/factory/etc, because the image ships only /usr. At boot,
|
||||
# mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf links from it what /etc needs.
|
||||
set -euo pipefail
|
||||
|
||||
cp -a --no-target-directory --update=none "$BUILDROOT/etc" \
|
||||
"$BUILDROOT/usr/share/factory/etc"
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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.
|
||||
podman # Jobs build and run containers.
|
||||
curl
|
||||
tar # actions/cache and artifacts use these.
|
||||
gzip
|
||||
zstd
|
||||
findutils
|
||||
+12
-9
@@ -1,11 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Installs the Gitea runner from gitea.com.
|
||||
set -eu
|
||||
v=5.4.1
|
||||
f=gitea-runner-$v-linux-amd64.xz
|
||||
#!/bin/bash
|
||||
# mkosi.prepare installs the Gitea runner from its releases on gitea.com, as
|
||||
# /usr/bin/gitea-runner. Fedora doesn't package it. The checksum file comes
|
||||
# from the same release, so it catches a broken download, not a bad release.
|
||||
set -euo pipefail
|
||||
version=6.0.1
|
||||
file=gitea-runner-$version-linux-amd64.xz
|
||||
|
||||
cd "$(mktemp -d)"
|
||||
curl -fsSLO "https://gitea.com/gitea/runner/releases/download/v$v/$f"
|
||||
curl -fsSLO "https://gitea.com/gitea/runner/releases/download/v$v/$f.sha256"
|
||||
sha256sum -c "$f.sha256"
|
||||
xz -dc "$f" > "$BUILDROOT/usr/bin/gitea-runner"
|
||||
curl -fsSLO "https://gitea.com/gitea/runner/releases/download/v$version/$file"
|
||||
curl -fsSLO "https://gitea.com/gitea/runner/releases/download/v$version/$file.sha256"
|
||||
sha256sum -c --quiet "$file.sha256"
|
||||
xz -dc "$file" > "$BUILDROOT/usr/bin/gitea-runner"
|
||||
chmod 755 "$BUILDROOT/usr/bin/gitea-runner"
|
||||
@@ -1,4 +1,5 @@
|
||||
# EFI system partition: systemd-boot and the UKIs (two versions at most).
|
||||
# 00-esp.conf defines the EFI system partition. It holds systemd-boot and the
|
||||
# UKIs, two versions at most.
|
||||
[Partition]
|
||||
Type=esp
|
||||
Format=vfat
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
# /usr, slot A: read-only erofs, protected by dm-verity (usrhash= in the UKI).
|
||||
# 10-usr.conf defines /usr in slot A: the OS as read-only erofs, protected by
|
||||
# dm-verity (usrhash= in the UKI). Updates replace it whole. The image holds
|
||||
# nothing else but the ESP: the initrd makes the root filesystem, with /etc
|
||||
# and /var, at first boot (mkosi.extra/usr/lib/repart.d/50-root.conf).
|
||||
[Partition]
|
||||
Type=usr
|
||||
Label=%M_%A
|
||||
Format=erofs
|
||||
Compression=zstd
|
||||
Compression=lz4hc
|
||||
CopyFiles=/usr:/
|
||||
Verity=data
|
||||
VerityMatchKey=usr
|
||||
SizeMinBytes=1G
|
||||
SizeMaxBytes=1G
|
||||
# SplitName holds the partition UUID (%U): usrhash= finds /usr by it, and
|
||||
# updates keep it (@u in mkosi.extra/usr/lib/sysupdate.d).
|
||||
SplitName=%t.%U
|
||||
@@ -1,8 +1,9 @@
|
||||
# dm-verity hashes of /usr, slot A.
|
||||
# 11-usr-verity.conf holds the dm-verity hashes of /usr in 10-usr.conf.
|
||||
[Partition]
|
||||
Type=usr-verity
|
||||
Label=%M_%A_verity
|
||||
Verity=hash
|
||||
VerityMatchKey=usr
|
||||
SizeMinBytes=64M
|
||||
SizeMaxBytes=64M
|
||||
SizeMinBytes=16M
|
||||
SizeMaxBytes=16M
|
||||
SplitName=%t.%U
|
||||
@@ -1,4 +1,5 @@
|
||||
# /usr, slot B: empty until systemd-sysupdate writes the next version.
|
||||
# 20-usr-b.conf defines /usr in slot B. It stays empty until systemd-sysupdate
|
||||
# writes the next version to it.
|
||||
[Partition]
|
||||
Type=usr
|
||||
Label=_empty
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# dm-verity hashes of /usr, slot B.
|
||||
# 21-usr-verity-b.conf holds the dm-verity hashes for 20-usr-b.conf, empty
|
||||
# until the next update.
|
||||
[Partition]
|
||||
Type=usr-verity
|
||||
Label=_empty
|
||||
SizeMinBytes=64M
|
||||
SizeMaxBytes=64M
|
||||
SizeMinBytes=16M
|
||||
SizeMaxBytes=16M
|
||||
SplitName=-
|
||||
@@ -1,8 +0,0 @@
|
||||
# The root filesystem: /etc and /var, kept across updates. Grows to fill the disk at boot.
|
||||
[Partition]
|
||||
Type=root
|
||||
Format=ext4
|
||||
CopyFiles=/
|
||||
ExcludeFilesTarget=/usr/
|
||||
Minimize=guess
|
||||
GrowFileSystem=yes
|
||||
+8
-3
@@ -1,3 +1,8 @@
|
||||
#!/bin/sh
|
||||
# The image version: the build time, so every build is newer than the last.
|
||||
date -u +%Y%m%d%H%M
|
||||
#!/bin/bash
|
||||
# mkosi.version prints the build time in UTC (YYYYMMDDhhmm) and the git
|
||||
# commit. Every build gets a higher version than the one before, which is how
|
||||
# systemd-sysupdate tells that an update is newer. The commit tells which
|
||||
# source an image was built from.
|
||||
set -euo pipefail
|
||||
commit=$(git rev-parse --short HEAD)
|
||||
echo "$(date -u +%Y%m%d%H%M).$commit"
|
||||
Reference in new issue
Block a user