Files
canopy-workloads/github_runner/README.md
T
kiskaadee 51445d4af1 feat(github_runner): author Nix-enabled ephemeral GitHub Actions runner stack (#11)
- .gitignore: ignore **/.env and **/app.env so runtime workload env files do not fail appctl clean-tree checks

- github_runner/Dockerfile & entrypoint-nix.sh: extend pinned myoung34/github-runner:ubuntu-noble with nixos/nix:2.24.12 seed, /etc/nix/nix.conf, non-root runner ownership, and single-line APP_PRIVATE_KEY_B64 decoding

- github_runner/docker-compose.yml: configure EPHEMERAL=true, RUN_AS_ROOT=false, DISABLE_AUTO_UPDATE=true, RUNNER_WORKDIR=/data/work, ../../var/lib/homelab/github_runner:/data, nix-store:/nix, and omit proxy-net for network isolation

- github_runner/app.yaml, .env-example, README.md & deployments.yaml: register github_runner (alias gh-runner) in admission registry and document GitHub App org permissions
2026-11-23 16:36:12 -05:00

29 lines
2.1 KiB
Markdown

# GitHub Actions Runner (`github_runner`)
Ephemeral, Nix-enabled self-hosted GitHub Actions runner built on `myoung34/github-runner:ubuntu-noble` with Nix (`nix-command` and `flakes` enabled) and GitHub App authentication.
## Architecture
- **Host-Mode Execution (No Docker Socket)**: Canopy forbids mounting `/var/run/docker.sock` or running privileged containers. Workflows run directly inside the runner container as the non-root `runner` user (`RUN_AS_ROOT=false`).
- **Ephemeral Lifecycle (`EPHEMERAL=true`)**: After completing a single job, the runner deregisters and exits `0`; Docker (`restart: unless-stopped`) restarts the container and `entrypoint-nix.sh` re-authenticates via the GitHub App for a clean runner instance.
- **Persistent State & Nix Cache**:
- Runner work directory: `../../var/lib/homelab/github_runner:/data` (`RUNNER_WORKDIR=/data/work`).
- Nix store cache: named Docker volume `nix-store:/nix` so evaluated derivations persist across ephemeral restarts. If `/nix/var/nix/profiles/default/bin/nix` is missing or broken, `entrypoint-nix.sh` seeds `/nix` from `/opt/nix-seed.tar.gz` and ensures `runner:runner` ownership.
- **Network Isolation**: Intentionally **not** attached to `proxy-net`; uses the default isolated Compose bridge for outbound HTTPS to GitHub only.
## GitHub App Permissions
Create and install a dedicated GitHub App on your organization (for **private** repositories):
- **Organization permissions**: `Self-hosted runners: Read and write`
- **Repository permissions**: `Metadata: Read-only`
## Configuration
See [`.env-example`](.env-example) for required runtime variables (stored in gitignored `.env`, `chmod 0640`):
- `GITHUB_RUNNER_SCOPE`: `org` (default) or `repo`
- `GITHUB_RUNNER_ORG_NAME`: Target GitHub organization slug (when `org`)
- `GITHUB_RUNNER_APP_ID`: GitHub App ID
- `GITHUB_RUNNER_APP_LOGIN`: GitHub App slug/login
- `GITHUB_RUNNER_APP_PRIVATE_KEY_B64`: Single-line base64-encoded PEM (`base64 -w0 < key.pem`), decoded at container startup into `APP_PRIVATE_KEY` for pure-Python `.env` compatibility.
- `GITHUB_RUNNER_LABELS`: Comma-separated runner labels (default `self-hosted,linux,x64,nix`).