feat(gitea_runner): configure host-mode Nix runner with persistent store
- Add gitea_runner/Dockerfile combining nixos/nix (flakes + nodejs + /bin/sleep) with act_runner binary and entrypoint - Update gitea_runner/docker-compose.yml to build locally, mount ~/var/lib/homelab/gitea_runner:/data and nix-store:/nix, remove DOCKER_HOST, and use :host runner labels - Add compose_build to gitea_runner/app.yaml deployment actions - Document runtime env vars and host-mode architecture in gitea_runner/.env-example and README.md
This commit is contained in:
1 parent
e42782f2f2
commit
d534399549
5 files changed
+59
-5
No files matched your search
@@ -0,0 +1,8 @@
|
||||
# Gitea Actions Runner environment variables (injected at runtime; never commit real tokens)
|
||||
GITEA_INSTANCE_URL=http://gitea:3000
|
||||
GITEA_RUNNER_TOKEN=replace-with-gitea-runner-registration-token
|
||||
GITEA_RUNNER_NAME=homelab-runner
|
||||
GITEA_RUNNER_LABELS=ubuntu-latest:host,nix:host
|
||||
|
||||
# Host state root (default: ~/var/lib/homelab; compose mounts ~/var/lib/homelab/gitea_runner:/data)
|
||||
HOMELAB_STATE_ROOT=~/var/lib/homelab
|
||||
@@ -0,0 +1,22 @@
|
||||
FROM gitea/act_runner:latest AS act-runner
|
||||
|
||||
FROM nixos/nix:latest
|
||||
|
||||
# Enable flakes and nix-command for CI workflows
|
||||
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
|
||||
|
||||
# Install Node.js (required by standard GitHub/Gitea Actions JS actions)
|
||||
RUN nix-env -iA nixpkgs.nodejs \
|
||||
&& nix-collect-garbage -d
|
||||
|
||||
# Ensure /bin/sleep exists (required by act_runner init)
|
||||
RUN mkdir -p /bin \
|
||||
&& ln -sf "$(command -v sleep)" /bin/sleep
|
||||
|
||||
# Copy static act_runner binary and entrypoint from official image
|
||||
COPY --from=act-runner /usr/local/bin/act_runner /usr/local/bin/act_runner
|
||||
COPY --from=act-runner /usr/local/bin/run.sh /usr/local/bin/run.sh
|
||||
|
||||
ENV PATH="/usr/local/bin:/root/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/bin:/bin"
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/run.sh"]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Gitea Actions Runner (`gitea_runner`)
|
||||
|
||||
Standalone `act_runner` for Gitea Actions, built with Nix (`nix-command` and `flakes` enabled), `git`, `bash`, and `nodejs` for **host-mode (`:host`)** execution.
|
||||
|
||||
## Architecture
|
||||
|
||||
- **Host-Mode Execution (`:host`)**: Core platform security bans direct Docker socket mounts and enforces a read-only `socket-proxy` (`POST=0`), so `act_runner` cannot spawn `docker://` job containers. Jobs run directly inside the runner container via `:host` labels (`ubuntu-latest:host,nix:host`).
|
||||
- **Persistent State & Nix Cache**:
|
||||
- Runner registration and workspace state: `~/var/lib/homelab/gitea_runner:/data` (under `HOMELAB_STATE_ROOT`, default `~/var/lib/homelab`).
|
||||
- Nix store cache: named Docker volume `nix-store:/nix` so evaluated derivations persist across rebuilds.
|
||||
|
||||
## Configuration
|
||||
|
||||
See [`.env-example`](.env-example) for required runtime variables:
|
||||
|
||||
- `GITEA_INSTANCE_URL`: Internal or external Gitea URL (default `http://gitea:3000` over `proxy-net`).
|
||||
- `GITEA_RUNNER_TOKEN`: One-time runner registration token (injected into `GITEA_RUNNER_REGISTRATION_TOKEN` in Compose).
|
||||
- `GITEA_RUNNER_NAME`: Runner display name (default `homelab-runner`).
|
||||
- `GITEA_RUNNER_LABELS`: Comma-separated `:host` labels (default `ubuntu-latest:host,nix:host`).
|
||||
@@ -14,4 +14,5 @@ deployment:
|
||||
branch: "main"
|
||||
actions:
|
||||
- git_pull
|
||||
- compose_build
|
||||
- compose_up
|
||||
@@ -1,19 +1,23 @@
|
||||
services:
|
||||
gitea_runner:
|
||||
image: gitea/act_runner:${ACT_RUNNER_VERSION:-latest}
|
||||
container_name: ${CONTAINER_NAME:-gitea-runner}
|
||||
build: .
|
||||
image: ${RUNNER_IMAGE:-gitea-runner:local}
|
||||
container_name: ${CONTAINER_NAME:-gitea_runner}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- GITEA_INSTANCE_URL=${GITEA_INSTANCE_URL:-http://gitea:3000}
|
||||
- GITEA_RUNNER_REGISTRATION_TOKEN=${GITEA_RUNNER_TOKEN:-}
|
||||
- GITEA_RUNNER_NAME=${GITEA_RUNNER_NAME:-homelab-runner}
|
||||
- GITEA_RUNNER_LABELS=${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-latest,ubuntu-22.04:docker://ghcr.io/catthehacker/ubuntu:act-latest}
|
||||
- DOCKER_HOST=${DOCKER_HOST:-tcp://docker-socket-proxy:2375}
|
||||
- GITEA_RUNNER_LABELS=${GITEA_RUNNER_LABELS:-ubuntu-latest:host,nix:host}
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- ~/var/lib/homelab/gitea_runner:/data
|
||||
- nix-store:/nix
|
||||
networks:
|
||||
- proxy-net
|
||||
|
||||
volumes:
|
||||
nix-store: {}
|
||||
|
||||
networks:
|
||||
proxy-net:
|
||||
name: ${PROXY_NETWORK:-proxy-net}
|
||||
|
||||
Reference in new issue
Block a user