A spare-machine Gitea forge, hardened, backed up and with CI, as a template. Personal values are placeholders listed in the README.
6.4 KiB
type, purpose, answers, cites
| type | purpose | answers | cites | |||
|---|---|---|---|---|---|---|
| Guide | Run a Gitea Actions runner on the server and the profile snake job. |
|
|
12 — Gitea Actions (CI)
A CI runner on the server, and its first job: a snake that eats the contribution heatmap on the Gitea profile page. Uses the same workflow syntax as GitHub Actions. It needs no new port forward: the runner polls Gitea over HTTPS like any other client.
Design
| Choice | Why |
|---|---|
| act_runner 0.6.1 as a compose service | Starts and stops with the stack and survives reboots through restart: unless-stopped. Pinned, like the Gitea image. |
| Jobs in sibling containers via the host Docker socket | Every job starts in a clean container. The socket is root on the host, so anyone who can push a workflow owns the box. That is acceptable only because registration is disabled and the runner is scoped to one user (§2). Revisit before adding users. |
docker_host: "-" |
Jobs themselves do not get the socket. A workflow cannot start containers or reach the host's Docker. |
Label alpine → node:24-alpine |
The image is 62 MB, against several GB for the Ubuntu runner images, which matters on the HDD. Most JS actions and npx work. A copied GitHub workflow with runs-on: ubuntu-latest sits queued and does not break. Add Ubuntu labels on a server with more RAM and an SSD. |
| Capacity 1, 768M per job, no cache server | Sized for 3G RAM total: Gitea, Caddy and an apex site use about 500M, leaving about 1.9G. Raise it on a bigger machine. |
Instance URL is the public https://git.example.com |
Job containers clone and push through the same URL that github.server_url gives them. The server reaches its own domain by NAT hairpin (check your router supports it). |
| Not in the backup | runner-data/ holds only the registration (.runner). If it is lost, register again (§2). Workflows live in their repos, which are in gitea-data. |
Files
| Repo path | Purpose |
|---|---|
compose.yml → runner |
the service; GITEA__actions__ENABLED=true on gitea |
runner/config.yaml |
runner config, mounted read-only |
runner-data/ (gitignored, server only) |
.runner registration state |
profile/ |
content of the yourname/.profile repo (§4) |
Setup (one-time, in order)
1. Copy the files to the server
From this repo on your workstation:
for f in compose.yml runner/config.yaml; do
ssh -p 2234 admin@192.168.1.50 "mkdir -p ~/mithlond/$(dirname $f) && cat > ~/mithlond/$f" < $f
done
runner/config.yaml must exist before step 3. If it is missing, Docker
creates an empty directory in its place and the runner fails to start.
2. Get a user-scoped registration token
In the browser: avatar → Settings → Actions → Runners → Create new
Runner (https://git.example.com/user/settings/actions/runners). Copy
the token.
Use this page and not Site Administration → Runners. A user-scoped runner only takes jobs from your own repos.
On the server, type it in (it is not echoed and stays out of shell history):
mkdir -p ~/mithlond/runner-data
read -rsp 'token: ' t && printf '%s' "$t" > ~/mithlond/runner-data/registration-token && unset t; echo
wc -c ~/mithlond/runner-data/registration-token # about 40, not 0
3. Start
cd ~/mithlond
docker compose up -d # recreates gitea (env changed) + starts runner
docker logs runner 2>&1 | grep -E 'registered|declare|error'
Expect Runner registered successfully and then declare successfully. Then
remove the token, which is single-use and no longer needed:
rm ~/mithlond/runner-data/registration-token
The runner shows Idle with label alpine on the Runners page from step 2.
4. The snake on your profile page
Gitea shows the README of a repo named .profile on the user's profile page.
-
In the browser, create the repo
yourname/.profile: empty, public. The SVGs are embedded by raw URL, so the repo must be readable anonymously. -
Push the template from your workstation. Copy it out first, because a
git initinsideprofile/would nest a repo within mithlond:cp -r ~/Documents/mithlond/profile ~/dot-profile && cd ~/dot-profile git init -b main && git add . && git commit -m "feat: snake on the profile page" git remote add origin ssh://git@git.example.com:2222/yourname/.profile.git git push -u origin main -
The push triggers the workflow. Follow it at
https://git.example.com/yourname/.profile/actions. The first run pullsnode:24-alpine. After that a run takes well under a minute. -
The workflow creates the
outputbranch, and the snake appears athttps://git.example.com/yourname.
After that it runs daily at 05:00, outside the 03:30 backup window when Gitea
is stopped. Actions → snake → Run workflow re-runs it on demand. Edit
README.md in that repo freely; keep the <picture> block.
The snake only has what the heatmap has: public activity. If the graph is nearly empty, the animation is short.
Checks
docker compose ps # runner Up
docker logs --since 24h runner 2>&1 | tail -20 # no repeating errors
curl -sI https://git.example.com/yourname/.profile/raw/branch/output/snake.svg | head -1 # 200
During the nightly backup the runner logs connection errors for about a minute while Gitea is stopped. That is expected, and it recovers by itself.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
| Job stuck Waiting | No runner has the label. runs-on must be alpine. |
runner registration token not found, wc -c shows 80, 120… |
Hidden read -s prompt took the paste more than once (e.g. 320 = 8×40). head -c 40 f > f.new && mv f.new f, then docker compose restart runner. |
Runner restarts in a loop, logs mention registration-token |
Token file missing or stale on first start. Repeat §2 and docker compose up -d runner. |
push step: 403 / permission denied |
The automatic token has no write access. Check Repo → Settings → Actions is enabled, and that the job is not running for a fork. |
| Snake missing on profile, raw URL 404 | No successful run yet, or the repo is private. |
Need to re-register (new server, lost runner-data/) |
Delete the old runner in the UI, rm -rf runner-data, then §2–§3. |