forgejo Runner (again)

Notes on how to add a runner to your forgejo instance. (Will probably work with CodeBerg)


I have developed a fips plugin that makes CI for C++ easy … for me anyway. I’m now awaiting CI completion before I can merge … because I always test before merging! So, naturally, here’s a guide for future me to add another Foregjo Runner to my setup.

Basic Details

I’m going to give the new runner the label daz1 to be consistent with the old runner. All other names for the new runner will be daz1_2 to emphasise it’s the same thing.

The old computers I’m using came from “daz” so that’s how they started getting numbered like that.

Open the Forgejo instance, go to your user settings, select “Actions” then “Runners” to see a list of your runners.

… oohhh! codeberg.org has some free runners avialable?

Select the “Create new runner” and copy/paste that wiggliboi key somewhere for later.

Prepare Your Host

I have a MacMini with an A1347 model number on the case - weirdly, it has an Intel LPC Controller. Weird.

I formatted it with Debian and skipped the GUI. I set it up as an SSH host (then switched back to the real computer - a Steam Deck) and got ready to install the software.

Docker

You need to do two things to get Docker working;

  • add the apt keys
  • install with apt

Apt Keys

From the guide, I got this blob of nonsense …

Guide https://docs.docker.com/engine/install/debian/#install-using-the-repository

Nonsense;

# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

Run it or discern your own.

Install Docker

The guide also lists … a lot of packages. This is what happens when you let neurotypicals (or masking divergents) write technical documents; they feel the need to fill the air.

All you really need to do is λ sudo apt install docker-ce, and Docker will be installed. Those other packages are dependencies of docker-ce so docker-ce will install them for you.

Once that’s done, you need to allow yourself to use Docker.

λ sudo /usr/sbin/usermod -aG docker peter

As usual, you’ll need to logout/login to refresh group membership IDK why usermod isn’t in path anymore … but that worked for me.

Acctttuuuuaaaaallllllyyyyyyy

I had to λ su && /usr/sbin/usermod -aG sudo peter && exit first so I could use sudo

Anyway …

Once you’ve logged-out/logged-back-in you can proceed with creating the actual runner!

Create the Runner

The runner is created in two steps.

  • register the runner instance/container so that the service/thing knows what to do
  • deploy the runner container/whatnot itself as a perpetual program

Register the Runner

I want to use an on-disk folder for the Docker volume - because. So I need a folder.

λ mkdir -p ~/daz1_2.volume

For my/our sanity, one needs/wants to pull an image for the runner. The Abominable Intellect told me to use version 11 at some point, so let’s do that.

λ docker pull code.forgejo.org/forgejo/runner:11

If the pull fails - something is wrong, and I don’t know what. I do know that :latest seemed to be missing … which is weird, but believable.

The big step now is to run the container in “registration mode” as shown here;

λ docker run -it --rm \
 -v /var/run/docker.sock:/var/run/docker.sock \
  -v ~/daz1_2.volume:/data \
 code.forgejo.org/forgejo/runner:11 \
  forgejo-runner register 

You can see;

  • it’s interactive, and discards on exit
    • We’ll specify the details by hand
    • This is fine; our changes are to the volume itself
  • the Docker pipe mounted … for some reason
  • the volume folder mounted as a volume
  • the version 11 container in question
  • the different command

You should be prompted for …

  • the forgejo instance; this is the website you log in to
  • the runner token; this is the wiggliboi you copied
  • the runner’s name; you know it!

… and at the end you should see some more messages ending with …

DEBU Successfully pinged the Forgejo instance server 
INFO Runner registered successfully.

… which means you won! So the next/last step is to actually start the runner.

Run the Runner (Forever!)

There’s some shananigans with the groupid. The container needs to be set to use the correct groupid - OR ELSE - it won’t be able to access the pipe socket. (… and your house will gain spiders)

To accomplish all this, just run this command …

λ docker run -d --name daz1_2 --restart always \
 -v /var/run/docker.sock:/var/run/docker.sock \
  -v ~/daz1_2.volume:/data \
 --group-add $(getent group docker | cut -d: -f3) \
  code.forgejo.org/forgejo/runner:11 \
 forgejo-runner daemon

… cool, so what are these? Well, they’re …

  • run the Docker command detached
  • Use the name daz1_2
  • always restart this container
  • The Docker pipe is mounted into the container
    • … because the runner needs it
  • the volume folder mounted as a volume
  • we engage in some sorcery to use the correct group ID
  • the same version 11 Docker image is used
  • We run the “daemon” command this time

So.

So so.

So that’s that. The runner should now show up on your ForgeJo instance, and it should run jobs associated with the label.

Stretch Goal: Enable Boot After Power Failure on Linux

https://gist.github.com/coldie/072d8e97dfad89d424ba91641641511d#comments

Warhammer 40,000 … hmm …

  • Pariahs vs Legion of the Damned (Kill Team)
  • Spider/Scuttler Grots (Underworlds)
  • (Co-Op?) Skirmish in the Old World (if only there was some name which carried weight or slot in the GW roster)
  • Darkwater expansion with Cursed City models (or book/box to use a Spearhead as the enemies)

I have a MacMini with an A1347 model number on the case - weirdly, it has an Intel LPC Controller. Weird.

Anyway, I want it to turn on when power is restored.

I ran the commands in the gist above … and sync … and it seems to have worked.

λ lspci | grep LPC
00:1f.0 ISA bridge: Intel Corporation HM65 Express Chipset Family LPC Controller (rev 05)

λ sudo setpci -s 00:1f.0 0xa4.w
9809

λ sudo setpci -s 00:1f.0 0xa4.w=9808

λ sudo setpci -s 00:1f.0 0xa4.w
9808

λ sync
λ sync
λ sync

So that’s neat, I guess.

comments powered by Disqus
Peter LaValle avatar
Peter LaValle
Any links probably include affiliate ids for that sweet sweet kickback - and some programs require that I tell you. The contents of this blog are likely unrelated - as they include games, paints, and build tools.