mkosi-based Gitea runner OS and job image
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
33 files changed
+529
No files matched your search
@@ -0,0 +1,28 @@
|
|||||||
|
# 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"
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# git-runner OS image
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
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
|
||||||
|
|
||||||
|
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 }}
|
||||||
|
steps:
|
||||||
|
- name: Install tools
|
||||||
|
run: dnf install -yq git-core mkosi jq
|
||||||
|
- name: Check out
|
||||||
|
uses: builtin:checkout
|
||||||
|
- name: Build
|
||||||
|
env:
|
||||||
|
SECUREBOOT_KEY: ${{ secrets.SECUREBOOT_KEY }}
|
||||||
|
run: |
|
||||||
|
(umask 077; printenv SECUREBOOT_KEY > mkosi.key)
|
||||||
|
mkosi --secure-boot=yes 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
|
||||||
|
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
|
||||||
|
working-directory: mkosi.output
|
||||||
|
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'
|
||||||
|
working-directory: mkosi.output
|
||||||
|
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"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Build outputs, and the Secure Boot key for local signed builds.
|
||||||
|
mkosi.output/
|
||||||
|
mkosi.key
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# 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
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
[Distribution]
|
||||||
|
Distribution=fedora
|
||||||
|
Release=45
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
Format=disk
|
||||||
|
ImageId=git-runner
|
||||||
|
OutputDirectory=mkosi.output
|
||||||
|
# The UKI and /usr partitions are published as updates (systemd-sysupdate).
|
||||||
|
SplitArtifacts=uki,partitions
|
||||||
|
|
||||||
|
[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
|
||||||
|
WithDocs=no
|
||||||
|
Locale=C.UTF-8
|
||||||
|
# The UKI's file name in the ESP, as systemd-sysupdate names the ones it installs.
|
||||||
|
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.
|
||||||
|
KernelInitrdModules=
|
||||||
|
virtio_blk
|
||||||
|
virtio_scsi
|
||||||
|
sd_mod
|
||||||
|
nvme
|
||||||
|
dm-verity
|
||||||
|
erofs
|
||||||
|
ext4
|
||||||
@@ -0,0 +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==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# 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"]
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# 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).
|
||||||
|
[Partition]
|
||||||
|
Type=root
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# DHCP on the real network cards. Kind=!* skips virtual links like the veths of podman's bridges,
|
||||||
|
# which netavark manages.
|
||||||
|
[Match]
|
||||||
|
Type=ether
|
||||||
|
Kind=!*
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
DHCP=yes
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# 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,17 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# First boot: asks for the root password and the runner's registration on the console (tty1).
|
||||||
|
[Unit]
|
||||||
|
Description=Gitea runner first-boot setup
|
||||||
|
ConditionPathExists=!/etc/gitea-runner/runner.env
|
||||||
|
Before=getty@tty1.service kmsconvt@tty1.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
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,24 @@
|
|||||||
|
# The Gitea Actions runner. Registers itself on its first start.
|
||||||
|
[Unit]
|
||||||
|
Description=Gitea Actions runner
|
||||||
|
Wants=network-online.target gitea-runner-images.service
|
||||||
|
After=network-online.target podman.socket gitea-runner-images.service
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# 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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# The runner may use root's podman. Jobs never get this socket.
|
||||||
|
[Socket]
|
||||||
|
SocketGroup=gitea-runner
|
||||||
|
SocketMode=0660
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# 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).
|
||||||
|
[Service]
|
||||||
|
ExecStartPre=/bin/sh -c '/usr/lib/systemd/systemd-sysupdate pending || exit 0; systemctl stop gitea-runner'
|
||||||
|
TimeoutStartSec=40min
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Updates /usr: writes the next version to the unused /usr partition.
|
||||||
|
[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
|
||||||
|
|
||||||
|
[Target]
|
||||||
|
Type=partition
|
||||||
|
Path=auto
|
||||||
|
MatchPattern=git-runner_@v
|
||||||
|
MatchPartitionType=usr
|
||||||
|
PartitionFlags=0
|
||||||
|
ReadOnly=1
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Updates the dm-verity hashes of /usr, next to 10-usr.transfer.
|
||||||
|
[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
|
||||||
|
|
||||||
|
[Target]
|
||||||
|
Type=partition
|
||||||
|
Path=auto
|
||||||
|
MatchPattern=git-runner_@v_verity
|
||||||
|
MatchPartitionType=usr-verity
|
||||||
|
PartitionFlags=0
|
||||||
|
ReadOnly=1
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# 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.
|
||||||
|
[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
|
||||||
|
|
||||||
|
[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
|
||||||
|
TriesLeft=3
|
||||||
|
TriesDone=0
|
||||||
|
InstancesMax=2
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# The runner's user.
|
||||||
|
u gitea-runner - "Gitea Actions runner" /var/lib/gitea-runner
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# 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.
|
||||||
|
R /var/lib/containers/storage
|
||||||
Executable
+25
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# First boot: ask for the root password and the runner's registration.
|
||||||
|
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."
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Installs the Gitea runner from gitea.com.
|
||||||
|
set -eu
|
||||||
|
v=5.4.1
|
||||||
|
f=gitea-runner-$v-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"
|
||||||
|
chmod 755 "$BUILDROOT/usr/bin/gitea-runner"
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# EFI system partition: systemd-boot and the UKIs (two versions at most).
|
||||||
|
[Partition]
|
||||||
|
Type=esp
|
||||||
|
Format=vfat
|
||||||
|
CopyFiles=/efi:/
|
||||||
|
CopyFiles=/boot:/
|
||||||
|
SizeMinBytes=256M
|
||||||
|
SizeMaxBytes=256M
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# /usr, slot A: read-only erofs, protected by dm-verity (usrhash= in the UKI).
|
||||||
|
[Partition]
|
||||||
|
Type=usr
|
||||||
|
Label=%M_%A
|
||||||
|
Format=erofs
|
||||||
|
Compression=zstd
|
||||||
|
CopyFiles=/usr:/
|
||||||
|
Verity=data
|
||||||
|
VerityMatchKey=usr
|
||||||
|
SizeMinBytes=1G
|
||||||
|
SizeMaxBytes=1G
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# dm-verity hashes of /usr, slot A.
|
||||||
|
[Partition]
|
||||||
|
Type=usr-verity
|
||||||
|
Label=%M_%A_verity
|
||||||
|
Verity=hash
|
||||||
|
VerityMatchKey=usr
|
||||||
|
SizeMinBytes=64M
|
||||||
|
SizeMaxBytes=64M
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# /usr, slot B: empty until systemd-sysupdate writes the next version.
|
||||||
|
[Partition]
|
||||||
|
Type=usr
|
||||||
|
Label=_empty
|
||||||
|
SizeMinBytes=1G
|
||||||
|
SizeMaxBytes=1G
|
||||||
|
SplitName=-
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# dm-verity hashes of /usr, slot B.
|
||||||
|
[Partition]
|
||||||
|
Type=usr-verity
|
||||||
|
Label=_empty
|
||||||
|
SizeMinBytes=64M
|
||||||
|
SizeMaxBytes=64M
|
||||||
|
SplitName=-
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# 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
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# The image version: the build time, so every build is newer than the last.
|
||||||
|
date -u +%Y%m%d%H%M
|
||||||
Reference in new issue
Block a user