CI runner (for maintainers)
Only the maintainer hosting the runner needs this page; contributors' merge requests use the project's runner.
The runner is a project runner for tarkam/knowtation on a maintainer's Linux machine: a Podman container managed by systemd (Quadlet), running jobs one at a time as sibling containers through the rootless Podman socket. Pipelines run only while that machine is on. The runner starts at boot (no login needed) and restarts after the machine wakes from sleep. Jobs that fail because the runner was away (stuck, timed out, runner failure) are retried automatically, twice; after that, retry them by hand.
Set up a runner
Requirements: Podman 4.4 or later (Quadlet) and systemd user services.
- Turn on the rootless Podman socket, and create a private config directory:
bash
systemctl --user enable --now podman.socket
mkdir -p ~/.config/gitlab-runner && chmod 700 ~/.config/gitlab-runner
-
Create the runner in GitLab: Settings → CI/CD → Runners → New project runner. Leave the tags empty and tick Run untagged jobs, because the jobs have no tags. Copy the
glrt-token. It is shown only once, and it is a secret: never paste it into a chat, an issue or a file in a repository. -
Register. The token is read from a hidden prompt, so it stays out of your shell history:
bash
printf 'Runner token (glrt-…): '; read -rs RUNNER_TOKEN; echo
podman run --rm -v "$HOME/.config/gitlab-runner:/etc/gitlab-runner:Z" \
docker.io/gitlab/gitlab-runner:alpine-v19.5.0 register --non-interactive \
--url https://gitlab.tarkam.org \
--token "$RUNNER_TOKEN" \
--name "$(hostname)" \
--executor docker \
--docker-image alpine:latest \
--docker-host unix:///var/run/docker.sock \
--docker-pull-policy if-not-present
unset RUNNER_TOKEN
Then add request_concurrency = 2 under name = … in ~/.config/gitlab-runner/config.toml, so the runner doesn't wait on long polling. That file holds the token, so keep it chmod 600 and outside any repository.
- Save this unit as
~/.config/containers/systemd/gitlab-runner.container:
```ini [Unit] Description=GitLab Runner (project runner for tarkam/knowtation on gitlab.tarkam.org) Requires=podman.socket After=podman.socket
[Container] Image=docker.io/gitlab/gitlab-runner:alpine-v19.5.0 ContainerName=gitlab-runner Volume=%h/.config/gitlab-runner:/etc/gitlab-runner:Z Volume=%t/podman/podman.sock:/var/run/docker.sock # With SELinux enforcing, the container can only reach the Podman socket unlabelled SecurityLabelDisable=true
[Service] Restart=on-failure
[Install] WantedBy=default.target ```
- Start it:
bash
systemctl --user daemon-reload
systemctl --user start gitlab-runner.service
The runner should show a green dot under Settings → CI/CD → Runners. To start it at boot rather than at login, and keep it running after logout:
bash
loginctl enable-linger
- Restart it after sleep. A job running when the machine sleeps leaves the runner hung, polling no more jobs. Save this script as
~/.local/bin/gitlab-runner-on-resumeand make it executable (chmod +x):
sh
#!/bin/sh
# Restart the GitLab Runner whenever the machine resumes from sleep (logind's PrepareForSleep
# signal with "false").
while :; do
signal=$(busctl --system wait /org/freedesktop/login1 org.freedesktop.login1.Manager PrepareForSleep) || exit 1
if [ "$signal" = "b false" ]; then
echo "resumed: restarting gitlab-runner"
systemctl --user restart gitlab-runner.service
fi
done
busctl wait needs systemd 257 or later. Save this unit as ~/.config/systemd/user/gitlab-runner-resume.service:
```ini [Unit] Description=Restart the GitLab Runner after the machine resumes from sleep After=gitlab-runner.service
[Service] ExecStart=%h/.local/bin/gitlab-runner-on-resume Restart=always RestartSec=10
[Install] WantedBy=default.target ```
Then run systemctl --user daemon-reload && systemctl --user enable --now gitlab-runner-resume.
Day-to-day
| Task | Command |
|---|---|
| Status | systemctl --user status gitlab-runner |
| Runner log | podman logs --since 1h gitlab-runner |
| Finished jobs | podman logs gitlab-runner 2>&1 \| grep -E 'Job (succeeded\|failed)' |
| Restarts after sleep | journalctl --user -u gitlab-runner-resume |
| Restart | systemctl --user restart gitlab-runner |
| Stop for now | systemctl --user stop gitlab-runner |
Job output itself is in GitLab: Build → Pipelines, then open a job. Each job log ends with Job succeeded or an error.
Upgrade
Change the image tag in the unit, for example alpine-v19.5.0 → a newer alpine-v…, then run systemctl --user daemon-reload && systemctl --user restart gitlab-runner. Keep the runner's major.minor version close to the GitLab server's (avatar → Help shows it).
Remove
systemctl --user disable --now gitlab-runner-resume
systemctl --user stop gitlab-runner
rm ~/.config/systemd/user/gitlab-runner-resume.service ~/.local/bin/gitlab-runner-on-resume
rm ~/.config/containers/systemd/gitlab-runner.container
systemctl --user daemon-reload
Then delete the runner in Settings → CI/CD → Runners, which revokes its token, and delete ~/.config/gitlab-runner/.
Moving it
To move the runner to an always-on machine, set it up there with the steps above, check it goes green, then remove the old one.