forg3jo Runn3r Setup
It’s my yearly update to how I launch codeberg / forgejo runners.
Rather than running on the bare system, we’re running our runner in a Docker container with access to the Docker Pipe.
LLMs will say that giving a Docker container access to the Docker Pipe is bad because it means the container can laucnh other containers. The advice I got was to just run the runner naked to avoid this.
… buuttt …
If you use all three braincells; you’ll realise that running the runner “naked” like that has even more exposure … so let’s do it the easy way.
Server Side Setup
Create a new runner on https://codeberg.org/user/settings/actions/runners or wahtever your instance is.
Give it a memorable name, meaningful description and note the UUID and TOKEN values, but, keep them secret.
Runner Setup
ssh into the computer that will run the runner.
Create a folder ~/runner/ and ~/runner/config.yml with the following content …
server:
connections:
forgejo:
url: https://codeberg.org/
uuid: {the UUID from the setup}
token: {that TOKEN from setup}
runner:
labels:
- {label 1}:docker://node:16
- {label 2}:docker://node:16
… and use whatever label ? values you want/need.
You can change them later … but I don’t know what happens with the second half of that thing.
Next, run getent group docker and look for the GID, probably 999 or 671 …
plava@olym:~$ getent group docker
docker:x:671:plava,runner
plava@olym:~$
… cool; it’s 671 there so it goes into docker-compose.yml in the same folder like this …
services:
runner:
image: "data.forgejo.org/forgejo/runner:13"
restart: "unless-stopped"
volumes:
# Mount your host config file to a path inside the container
- ~/runner/config.yml:/config.yml:ro
# the host docker socket
- /var/run/docker.sock:/var/run/docker.sock
group_add:
# GID from `getent group docker`
- "{group id}"
environment:
- DOCKER_HOST=unix:///var/run/docker.sock
# Update the command to point to the mounted path
command: "forgejo-runner daemon --config /config.yml"
… which will run your runner.
YaY
Launch and Test
Now … now you just need to launch it. On my MacBook this was ….
docker compose up
… but on my Raspi3 it was …
docker-compose up
… so you might need two of those braincells again to get the correct command.
Why not
-d?That comes later - for now we want to see if this thing runs before we schedule it to run detached.
Test?
Find one of your ({owner-foo}) repos ({project-bar}) and in the “Units” section “Overview” enable “Actions” so that it knows to run your runners.
link https://codeberg.org/{owner-foo}/{project-bar}/settings/units
After that, create something like this .forgejo/workflows/prune.yml in https://codeberg.org/{owner-foo}/{project-bar}/ …
# prune docker things we're not using after a week
# ---
name: prune old docker data
on:
push:
branches:
- "*"
schedule:
- cron: "0 0 * * *"
jobs:
build:
strategy:
matrix:
runner:
# add your runner labels
# ... i run this on each computer
- ellen
- puppy
- leo
- beans
- roadb
- olym
- malise
- misty
- maria
runs-on: ${{ matrix.runner }}
steps:
- name: prune
run: docker system prune --filter "until=7d"
… and when you commit (and at midnight every day) it’ll run.
Probably.
Check the output from the window where you were running this.
… this won’t actually work … it doesn’t have Docker or the pipe in the container …
… but you can see what’s happening …
Conclusion / Button Up
When you’re satisfied - CTRL+C to close the “interactive” invoke and re-launch with docker-compose up -d so you can disconnect from the worker.
… you might also want to start writing different CI files …
So I like this - I’m using it now.
This post is replacing the old instructions and my private notes too!