Gitea Act Runner: DinD stack with cache + parallel jobs
Stable docker-compose setup for building Rust projects on Gitea Actions. DinD-isolated daemon, built-in cache server, capacity=4 parallel jobs, healthcheck-gated startup. Portable to other build machines via .env. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HU4wDwdydNZpR3YkMiYYy8
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# Copy to .env and fill in. Get a fresh registration token from:
|
||||
# Gitea -> Site Admin / Org / Repo -> Actions -> Runners -> Create Runner
|
||||
GITEA_INSTANCE_URL=https://git.vysma.dev
|
||||
GITEA_RUNNER_REGISTRATION_TOKEN=
|
||||
GITEA_RUNNER_NAME=changeme-worker
|
||||
|
||||
# NOTE: parallel-job count (capacity) is set in config.yaml -> runner.capacity
|
||||
@@ -0,0 +1,8 @@
|
||||
# Secrets — never commit the real registration token
|
||||
.env
|
||||
|
||||
# Runner local data (if ever bind-mounted)
|
||||
data/
|
||||
|
||||
# Tooling / session state
|
||||
.omc/
|
||||
@@ -0,0 +1,46 @@
|
||||
# Gitea Act Runner (DinD + cache)
|
||||
|
||||
Stable Gitea Actions runner for building Rust projects. Runs jobs in an isolated
|
||||
Docker-in-Docker daemon with the built-in cache server enabled and multiple
|
||||
parallel jobs.
|
||||
|
||||
## Setup on a new build machine
|
||||
|
||||
Requires Docker + Docker Compose.
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# edit .env: set GITEA_RUNNER_NAME (unique per machine) and a fresh
|
||||
# GITEA_RUNNER_REGISTRATION_TOKEN from Gitea -> Actions -> Runners -> Create Runner
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
Verify:
|
||||
|
||||
```bash
|
||||
docker compose ps # both containers up, dind healthy
|
||||
docker logs gitea-runner-wsl 2>&1 | tail # "declare successfully"
|
||||
```
|
||||
|
||||
## Config
|
||||
|
||||
- **Parallel jobs**: `config.yaml` -> `runner.capacity` (default 4)
|
||||
- **Job images**: `config.yaml` -> `runner.labels` (ubuntu-latest/22.04/24.04)
|
||||
- **Cache**: enabled in `config.yaml`; layer cache persists in the `dind-storage` volume
|
||||
|
||||
## Rust workflows
|
||||
|
||||
Copy `example-rust-workflow.yaml` to your repo at `.gitea/workflows/build.yaml`.
|
||||
It uses `actions-rust-lang/setup-rust-toolchain` which caches `~/.cargo` and
|
||||
`target/` via the runner's cache server.
|
||||
|
||||
## Manage
|
||||
|
||||
```bash
|
||||
docker compose up -d # apply config changes
|
||||
docker compose down # stop (registration persists in volume)
|
||||
docker compose pull # update runner/dind images
|
||||
```
|
||||
|
||||
> Each machine needs a unique `GITEA_RUNNER_NAME` and its own registration token.
|
||||
> Run `docker compose down -v` to fully reset (drops registration + caches).
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
log:
|
||||
level: info
|
||||
|
||||
runner:
|
||||
# Run multiple jobs concurrently. Overridden by env at compose level too.
|
||||
capacity: 4
|
||||
timeout: 3h
|
||||
# Keep the runner alive; jobs are ephemeral containers.
|
||||
insecure: false
|
||||
# Env injected into every job. Speeds up Rust builds.
|
||||
envs:
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_INCREMENTAL: "0"
|
||||
CARGO_NET_RETRY: "10"
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
# Labels decide which docker image runs each job. Jobs use `runs-on: ubuntu-latest`.
|
||||
labels:
|
||||
- "ubuntu-latest:docker://catthehacker/ubuntu:act-22.04"
|
||||
- "ubuntu-22.04:docker://catthehacker/ubuntu:act-22.04"
|
||||
- "ubuntu-24.04:docker://catthehacker/ubuntu:act-24.04"
|
||||
|
||||
cache:
|
||||
# Built-in cache server so actions/cache works (Rust deps, target/, etc.)
|
||||
enabled: true
|
||||
dir: ""
|
||||
# Empty host -> auto-detect outbound IP reachable from job containers.
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
# Talk to the DinD daemon, not the host.
|
||||
network: ""
|
||||
privileged: false
|
||||
options: ""
|
||||
workdir_parent: ""
|
||||
# Allow workflows to mount caches from the DinD volume.
|
||||
valid_volumes:
|
||||
- "**"
|
||||
docker_host: "-"
|
||||
force_pull: false
|
||||
|
||||
host:
|
||||
workdir_parent: ""
|
||||
@@ -0,0 +1,51 @@
|
||||
services:
|
||||
# Isolated Docker daemon for the runner's job containers.
|
||||
# Keeps the host Docker clean and gives reliable cache networking.
|
||||
dind:
|
||||
image: docker:27-dind
|
||||
container_name: gitea-runner-dind
|
||||
privileged: true
|
||||
restart: unless-stopped
|
||||
command: ["dockerd", "--host=tcp://0.0.0.0:2375", "--host=unix:///var/run/docker.sock", "--tls=false"]
|
||||
environment:
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
networks:
|
||||
- runner
|
||||
volumes:
|
||||
# Persist pulled job images + docker layer cache => fast Rust rebuilds.
|
||||
- dind-storage:/var/lib/docker
|
||||
healthcheck:
|
||||
test: ["CMD", "docker", "info"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
|
||||
runner:
|
||||
image: docker.io/gitea/act_runner:nightly
|
||||
container_name: gitea-runner-wsl
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
dind:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- runner
|
||||
environment:
|
||||
GITEA_INSTANCE_URL: ${GITEA_INSTANCE_URL}
|
||||
GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_REGISTRATION_TOKEN}
|
||||
GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME}
|
||||
GITEA_RUNNER_LABELS: ""
|
||||
# Point the runner at the DinD daemon.
|
||||
DOCKER_HOST: tcp://dind:2375
|
||||
CONFIG_FILE: /config.yaml
|
||||
volumes:
|
||||
- ./config.yaml:/config.yaml:ro
|
||||
# Persist runner registration so it survives restarts.
|
||||
- runner-data:/data
|
||||
|
||||
networks:
|
||||
runner:
|
||||
|
||||
volumes:
|
||||
dind-storage:
|
||||
runner-data:
|
||||
@@ -0,0 +1,20 @@
|
||||
# Copy to your repo at: .gitea/workflows/build.yaml
|
||||
name: Build Rust
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
# This action already wires Swatinem/rust-cache under the hood,
|
||||
# caching ~/.cargo registry + target/ via the runner's cache server.
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --locked
|
||||
|
||||
- name: Test
|
||||
run: cargo test --release --locked
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONTAINER_NAME=gitea-runner-wsl
|
||||
docker stop $CONTAINER_NAME
|
||||
docker rm $CONTAINER_NAME
|
||||
docker run \
|
||||
-e GITEA_INSTANCE_URL=https://git.vysma.dev \
|
||||
-e GITEA_RUNNER_REGISTRATION_TOKEN=hSaHcqGa82SlehNQ4GvoNmd863xovuBfZGM4jH0P \
|
||||
-e GITEA_RUNNER_NAME=nampdn-wsl \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
--name $CONTAINER_NAME \
|
||||
-d docker.io/gitea/act_runner:nightly
|
||||
|
||||
|
||||
Reference in New Issue
Block a user