Skip to navigation
FreeBSD Forgejo runner (act_runner) — setup
17.11.26
# FreeBSD Forgejo runner (act_runner) — setup Target: FreeBSD 15 (pkgbase) host, self-hosted Forgejo at `https://code.salamander-jewelry.net`. The runner executes jobs **directly on the FreeBSD host** (`host` mode) — no Docker, no VM. Outcome: `service forgejo_runner start|stop|status`, starts on every boot, jobs with `runs-on: freebsd` land here. Levels of trust: the runner token lives only in `runner-config.yml` with mode `600`; never commit it; recreate the runner if it leaks. --- ## Prerequisites 1. A Forgejo instance (here `https://code.salamander-jewelry.net`). 2. Create the runner registration in the UI *first*: repo or org → **Settings → Actions → Runners → Create new runner**. The UI shows you a **UUID** and a **Token** — you will paste both into `runner-config.yml` (Step 5). Keep them handy; they are effectively a password for this runner. 3. Your Forgejo's certificate is signed by the **minica** root CA. The host must trust it or the runner cannot connect (`x509: certificate signed by unknown authority`). See Step 6. --- ## 1. Find the package ```sh pkg search forgejo ``` On FreeBSD 15 pkgbase: `forgejo-act_runner-13.x` — this is the Forgejo runner (Gitea/Act compatible). ## 2. Install ```sh pkg install forgejo-act_runner ``` ### Check what was installed ```sh pkg info forgejo-act_runner | head -20 which act_runner # -> /usr/local/bin/act_runner act_runner --help act_runner register --help # registration via CLI is deprecated; use the UI flow ``` ## 3. Create the `runner` user and work directory ```sh pw useradd runner -m -s /usr/sbin/nologin mkdir -p /var/lib/forgejo-runner chown runner:runner /var/lib/forgejo-runner chmod 750 /var/lib/forgejo-runner ``` ### Check ```sh id runner # uid=1003(runner) gid=1003(runner) ... ls -ld /var/lib/forgejo-runner /home/runner # both owned runner:runner, /var/lib/forgejo-runner mode 750 ``` ## 4. Generate the config (as `runner`, not root) ```sh su - runner -s /bin/sh cd /var/lib/forgejo-runner act_runner generate-config > runner-config.yml ``` ### Check ```sh ls -l runner-config.yml cat runner-config.yml # note the commented sections (server / runner / container / cache) ``` ## 5. Edit `runner-config.yml` Two edits, no tabs, spaces only (use `ee` — FreeBSD default editor — or `vi`): ```sh ee runner-config.yml ``` 1. `runner:` → `labels:` (line ~77, empty `labels: []`) → ```yaml labels: - freebsd:host ``` `freebsd` is the label name — workflows match it with `runs-on: freebsd`. `host` means job steps run directly on this machine (no isolation). 2. `server:` → `connections:` (line ~270) → add indented under it: ```yaml connections: forgejo: url: https://code.salamander-jewelry.net/ uuid:
token:
``` URL exactly as shown in the UI; the connection name (`forgejo`) can be anything unique. Fix ownership once more (it will now hold the token), remove the editor's leftover backup: ```sh chown runner:runner runner-config.yml rm -f runner-config.yml~ # ee's backup contains the token chmod 600 runner-config.yml ``` ### Peek at the two regions you edited (safe, no secrets printed unless you keep them) ```sh sed -n '72,80p' runner-config.yml sed -n '265,280p' runner-config.yml ``` ## 6. Trust the minica root CA (required or TLS fails) The Forgejo cert is issued by the minica internal CA; `/etc/ssl/cert.pem` is rebuilt by `certctl rehash` from `/usr/share/certs` + `/usr/local/share/certs`. Create the ports dir if it does not exist: ```sh mkdir -p /usr/local/share/certs cp
/usr/local/share/certs/minica.pem certctl rehash ``` (`minica.pem` lives in the internal repo, e.g. `code/app/dockers/certs/minica.pem`.) ### Check ```sh ls -l /etc/ssl/cert.pem # timestamp should be new ``` Without this step, the daemon fails with `x509: certificate signed by unknown authority`. ## 7. Start it in the foreground (first test) ```sh su - runner -s /bin/sh cd /var/lib/forgejo-runner act_runner daemon -c runner-config.yml ``` Expected: ``` Starting runner daemon runner: freebsd, with version: 13.2.0, with labels: [freebsd], ephemeral: false, declared successfully [poller] launched ``` The runner flips to **online** in the Forgejo UI. `Ctrl-C` to stop (it listens for the signal and shuts down cleanly). ## 8. Install as a boot-time service ```sh cat > /usr/local/etc/rc.d/forgejo_runner << 'EOF' #!/bin/sh # PROVIDE: forgejo_runner # REQUIRE: NETWORKING # KEYWORD: shutdown . /etc/rc.subr name="forgejo_runner" rcvar="forgejo_runner_enable" desc="Forgejo Actions runner" pidfile="/var/run/forgejo_runner.pid" logfile="/var/log/forgejo_runner.log" run_cmd="/usr/local/bin/act_runner daemon -c /var/lib/forgejo-runner/runner-config.yml" start_cmd="forgejo_runner_start" stop_cmd="forgejo_runner_stop" status_cmd="forgejo_runner_status" forgejo_runner_start() { daemon -u runner -p "${pidfile}" -o "${logfile}" ${run_cmd} } forgejo_runner_stop() { if [ -f "${pidfile}" ]; then kill "$(cat ${pidfile})" 2>/dev/null rm -f "${pidfile}" else pkill -u runner -f 'act_runner daemon' fi } forgejo_runner_status() { if pgrep -u runner -f 'act_runner daemon' > /dev/null; then echo "forgejo_runner is running" else echo "forgejo_runner is not running" exit 1 fi } load_rc_config ${name} run_rc_command "$1" EOF chmod 755 /usr/local/etc/rc.d/forgejo_runner sysrc forgejo_runner_enable=YES service forgejo_runner start service forgejo_runner status tail /var/log/forgejo_runner.log ``` ### Checks ```sh service forgejo_runner status # forgejo_runner is running tail /var/log/forgejo_runner.log # declaration + poller lines, like Step 7 ``` After a reboot, `service forgejo_runner status` must report running — if not, `tail /var/log/forgejo_runner.log` shows why. --- ## Using it in a workflow ```yaml jobs: build: runs-on: freebsd # matches the label from Step 5 steps: - run: uname -a ``` Host mode means steps run on the FreeBSD box as the `runner` user (uid 1003) — no Docker, no container, no VM. Actions that need Node (e.g. `actions/checkout`) need Node installed on the host, or use plain shell steps.
Reply
Anonymous
Information Epoch 1795523553
Clarity is better than cleverness.
Home
Notebook
Contact us