5 Commits
Author SHA1 Message Date
kiskaadee 954cbc1c7f feat(github_runner): target canopy-homelab organization with RUNNER_SCOPE=org
- github_runner/docker-compose.yml: configure primary runner for RUNNER_SCOPE=org, ORG_NAME=canopy-homelab, APP_LOGIN=canopy-homelab, and state under ../../var/lib/homelab/github_runner/canopy-homelab

- github_runner/.env-example: keep .env strictly scoped to shared GitHub App ID, base64 key, and labels
2026-11-24 01:14:32 -05:00
kiskaadee 359ee51586 feat(github_runner): support shared App credentials and multi-org Compose anchors
- github_runner/docker-compose.yml: add x-runner-common/x-runner-env anchors so org runners can be added per-service without duplicating App credentials in .env; default primary runner to RUNNER_SCOPE=repo and APP_LOGIN=kiskaadee

- github_runner/.env-example: keep .env scoped to shared App ID, base64 key, labels, and personal repo URL
2026-11-23 17:36:36 -05:00
kiskaadee 1981398cf3 Merge branch 'fix/gitea-ratelimit-robots' 2026-11-23 16:47:18 -05:00
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
kiskaadee 9ff2a4c714 fix(gitea): add robots.txt and attach public-ratelimit Traefik middleware
- gitea/robots.txt: disallow crawler traps on /*/*/pulls, issues, commits, archive, graph, forks, stars, watchers, activity, and /explore

- gitea/docker-compose.yml: mount ./robots.txt read-only into /data/gitea/public/robots.txt and attach public-ratelimit@docker middleware
2026-11-23 16:25:02 -05:00
16 changed files with 156 additions and 16 deletions

No files matched your search

+2
View File
@@ -1,4 +1,6 @@
__pycache__/ __pycache__/
**/data/ **/data/
**/.env
**/app.env
.internal/ .internal/
.venv .venv
+1
View File
@@ -27,6 +27,7 @@ docker compose --env-file .env up -d
* **`deployments.yaml`**: Authoritative workload admission registry (`schemaVersion: "1.0"`). * **`deployments.yaml`**: Authoritative workload admission registry (`schemaVersion: "1.0"`).
* **`gitea/`**: Self-hosted Git service and code repository. * **`gitea/`**: Self-hosted Git service and code repository.
* **`gitea_runner/`**: Standalone Gitea Actions CI/CD runner (`act_runner`). * **`gitea_runner/`**: Standalone Gitea Actions CI/CD runner (`act_runner`).
* **`github_runner/`**: Ephemeral Nix-enabled GitHub Actions self-hosted runner.
* **`snappymail/`**: Lightweight webmail client. * **`snappymail/`**: Lightweight webmail client.
* **`jellyfin/`**: Media server and streaming hub. * **`jellyfin/`**: Media server and streaming hub.
* **`armonia/`**: Armonía del Ser API and operator dashboard. * **`armonia/`**: Armonía del Ser API and operator dashboard.
+3 -3
View File
@@ -3,7 +3,7 @@
DASHBOARD_REPO_URL=https://git.example.com/org/armonia-dashboard.git DASHBOARD_REPO_URL=https://git.example.com/org/armonia-dashboard.git
DASHBOARD_REF=main DASHBOARD_REF=main
# Pre-built container image reference for armonia-api # Pre-built container image reference for armonia-api
ARMONIA_API_IMAGE=homelab-armonia-armonia-api:latest ARMONIA_API_IMAGE=armonia-api:latest
# --- Runtime & Database --- # --- Runtime & Database ---
ENVIRONMENT=production ENVIRONMENT=production
@@ -22,8 +22,8 @@ AUTH_MIDDLEWARE=authelia-auth@docker
HTTPS_REDIRECT_MIDDLEWARE=https-redirect@docker HTTPS_REDIRECT_MIDDLEWARE=https-redirect@docker
# --- User/Group IDs --- # --- User/Group IDs ---
PUID=1001 PUID=1000
PGID=988 PGID=1000
# --- Application Settings --- # --- Application Settings ---
THERAPIST_NAME= THERAPIST_NAME=
+3 -3
View File
@@ -1,11 +1,11 @@
services: services:
armonia-api: armonia-api:
image: ${ARMONIA_API_IMAGE:-homelab-armonia-armonia-api:latest} image: ${ARMONIA_API_IMAGE:-armonia-api:latest}
container_name: ${ARMONIA_API_CONTAINER:-armonia-api} container_name: ${ARMONIA_API_CONTAINER:-armonia-api}
user: "${PUID:-1001}:${PGID:-988}" user: "${PUID:-1000}:${PGID:-1000}"
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ../../var/lib/homelab/armonia/data:/data - ./data:/data
environment: environment:
- ENVIRONMENT=${ENVIRONMENT:-production} - ENVIRONMENT=${ENVIRONMENT:-production}
- APP_ENV=${APP_ENV:-production} - APP_ENV=${APP_ENV:-production}
+4
View File
@@ -12,6 +12,10 @@ repositories:
aliases: aliases:
- "act_runner" - "act_runner"
- "runner" - "runner"
github_runner:
path: "~/Workloads/github_runner"
aliases:
- "gh-runner"
snappymail: snappymail:
path: "~/Workloads/snappymail" path: "~/Workloads/snappymail"
aliases: aliases:
+2
View File
@@ -19,6 +19,7 @@ services:
- "${SSH_PORT:-2223}:22" - "${SSH_PORT:-2223}:22"
volumes: volumes:
- ../../var/lib/homelab/gitea:/data - ../../var/lib/homelab/gitea:/data
- ./robots.txt:/data/gitea/public/robots.txt:ro
networks: networks:
- proxy-net - proxy-net
labels: labels:
@@ -28,6 +29,7 @@ services:
- "traefik.http.routers.${CONTAINER_NAME:-gitea}.entrypoints=${HTTPS_ENTRYPOINT:-websecure}" - "traefik.http.routers.${CONTAINER_NAME:-gitea}.entrypoints=${HTTPS_ENTRYPOINT:-websecure}"
- "traefik.http.routers.${CONTAINER_NAME:-gitea}.tls=true" - "traefik.http.routers.${CONTAINER_NAME:-gitea}.tls=true"
- "traefik.http.routers.${CONTAINER_NAME:-gitea}.tls.certresolver=${CERT_RESOLVER:-myresolver}" - "traefik.http.routers.${CONTAINER_NAME:-gitea}.tls.certresolver=${CERT_RESOLVER:-myresolver}"
- "traefik.http.routers.${CONTAINER_NAME:-gitea}.middlewares=${RATE_LIMIT_MIDDLEWARE:-public-ratelimit@docker}"
- "traefik.http.routers.${CONTAINER_NAME:-gitea}.service=${CONTAINER_NAME:-gitea}-svc" - "traefik.http.routers.${CONTAINER_NAME:-gitea}.service=${CONTAINER_NAME:-gitea}-svc"
# HTTP to HTTPS Redirect Router # HTTP to HTTPS Redirect Router
- "traefik.http.routers.${CONTAINER_NAME:-gitea}-red.rule=Host(`${SERVICE_DOMAIN}`)" - "traefik.http.routers.${CONTAINER_NAME:-gitea}-red.rule=Host(`${SERVICE_DOMAIN}`)"
+11
View File
@@ -0,0 +1,11 @@
User-agent: *
Disallow: /*/*/pulls
Disallow: /*/*/issues
Disallow: /*/*/commits
Disallow: /*/*/archive
Disallow: /*/*/graph
Disallow: /*/*/forks
Disallow: /*/*/stars
Disallow: /*/*/watchers
Disallow: /*/*/activity
Disallow: /explore
+5
View File
@@ -0,0 +1,5 @@
# Shared GitHub App credentials (injected at runtime; never commit real credentials)
GITHUB_RUNNER_APP_ID=replace-with-github-app-id
# Single-line base64-encoded GitHub App PEM private key: base64 -w0 < private-key.pem
GITHUB_RUNNER_APP_PRIVATE_KEY_B64=replace-with-base64-encoded-pem
GITHUB_RUNNER_LABELS=self-hosted,linux,x64,nix
+23
View File
@@ -0,0 +1,23 @@
FROM nixos/nix:2.24.12 AS nix-src
RUN tar -czf /nix-seed.tar.gz -C /nix .
FROM myoung34/github-runner:ubuntu-noble@sha256:4c5ebb26d973b16e55250de938a498afb2f7714ef391709f3abb9d8b666b8515
# Regular file (never a symlink into /nix/store) so nix-store volume mounts cannot break it
RUN mkdir -p /etc/nix /nix && \
printf '%s\n' \
'sandbox = false' \
'experimental-features = nix-command flakes' \
'trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' \
> /etc/nix/nix.conf
COPY --from=nix-src /nix /nix
COPY --from=nix-src /nix-seed.tar.gz /opt/nix-seed.tar.gz
COPY entrypoint-nix.sh /usr/local/bin/entrypoint-nix.sh
RUN chmod +x /usr/local/bin/entrypoint-nix.sh && \
chown -R runner:runner /nix
ENV PATH="/usr/local/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin"
ENTRYPOINT ["/usr/local/bin/entrypoint-nix.sh"]
CMD ["./bin/Runner.Listener", "run", "--startuptype", "service"]
+28
View File
@@ -0,0 +1,28 @@
# 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`).
+17
View File
@@ -0,0 +1,17 @@
schemaVersion: "1.0"
name: "github_runner"
aliases:
- "gh-runner"
domain: "internal"
description: "Ephemeral Nix-enabled GitHub Actions Self-Hosted Runner"
visible: false
auth: false
networks:
- default
deployment:
strategy: "compose"
branch: "main"
actions:
- git_pull
- compose_build
- compose_up
+29
View File
@@ -0,0 +1,29 @@
x-runner-common: &runner-common
image: ${RUNNER_IMAGE:-github-runner:local}
restart: unless-stopped
environment: &runner-env
EPHEMERAL: ${EPHEMERAL:-true}
RUN_AS_ROOT: "false"
DISABLE_AUTO_UPDATE: ${DISABLE_AUTO_UPDATE:-true}
RUNNER_WORKDIR: /data/work
APP_ID: ${GITHUB_RUNNER_APP_ID:-}
APP_PRIVATE_KEY_B64: ${GITHUB_RUNNER_APP_PRIVATE_KEY_B64:-}
LABELS: ${GITHUB_RUNNER_LABELS:-self-hosted,linux,x64,nix}
services:
github_runner:
<<: *runner-common
build: .
container_name: ${CONTAINER_NAME:-github_runner}
environment:
<<: *runner-env
RUNNER_NAME: ${GITHUB_RUNNER_NAME:-homelab-runner-canopy}
RUNNER_SCOPE: org
APP_LOGIN: canopy-homelab
ORG_NAME: canopy-homelab
volumes:
- ../../var/lib/homelab/github_runner/canopy-homelab:/data
- nix-store:/nix
volumes:
nix-store: {}
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail
if [ ! -x /nix/var/nix/profiles/default/bin/nix ] || ! /nix/var/nix/profiles/default/bin/nix --version >/dev/null 2>&1; then
echo "[entrypoint-nix] /nix/var/nix/profiles/default/bin/nix missing or broken; seeding /nix from /opt/nix-seed.tar.gz..." >&2
tar -xzf /opt/nix-seed.tar.gz -C /nix
fi
mkdir -p /data/work
chown -R runner:runner /nix /data
if [ -n "${APP_PRIVATE_KEY_B64:-}" ] && [ -z "${APP_PRIVATE_KEY:-}" ]; then
APP_PRIVATE_KEY="$(printf '%s' "${APP_PRIVATE_KEY_B64}" | base64 -d)"
export APP_PRIVATE_KEY
unset APP_PRIVATE_KEY_B64
fi
exec /entrypoint.sh "$@"
+3 -3
View File
@@ -6,8 +6,8 @@ SERVICE_DOMAIN=jellyfin.example.com
TZ=UTC TZ=UTC
# --- User/Group IDs --- # --- User/Group IDs ---
PUID=1001 PUID=1000
PGID=988 PGID=1000
# --- Path Configuration --- # --- Path Configuration ---
MEDIA_PATH=/path/to/your/media MEDIA_PATH=/path/to/your/media
@@ -16,7 +16,7 @@ MEDIA_PATH=/path/to/your/media
PROXY_NETWORK=proxy-net PROXY_NETWORK=proxy-net
HTTP_ENTRYPOINT=web HTTP_ENTRYPOINT=web
HTTPS_ENTRYPOINT=websecure HTTPS_ENTRYPOINT=websecure
CERT_RESOLVER=myresolver CERT_RESOLVER=letsencrypt
# --- Security & Performance --- # --- Security & Performance ---
RATE_LIMIT_AVG=100 RATE_LIMIT_AVG=100
+3 -3
View File
@@ -19,6 +19,6 @@ Refer to the root [README.md](../README.md) for details on how environment varia
## 📦 Volumes ## 📦 Volumes
- `../../var/lib/homelab/jellyfin/config`: Application data and configuration. - `./config`: Application data and configuration.
- `../../var/lib/homelab/jellyfin/cache`: Metadata and transcode cache. - `./cache`: Metadata and transcode cache.
- `../../var/lib/homelab/jellyfin/media`: Media library (mounted read-only). - `${MEDIA_PATH}`: Media library (mounted read-only).
+4 -4
View File
@@ -2,13 +2,13 @@ services:
jellyfin: jellyfin:
image: jellyfin/jellyfin:${IMAGE_TAG:-latest} image: jellyfin/jellyfin:${IMAGE_TAG:-latest}
container_name: ${CONTAINER_NAME:-jellyfin} container_name: ${CONTAINER_NAME:-jellyfin}
user: "${PUID:-1001}:${PGID:-988}" user: "${PUID:-1000}:${PGID:-1000}"
environment: environment:
- TZ=${TZ:-UTC} - TZ=${TZ:-UTC}
volumes: volumes:
- ../../var/lib/homelab/jellyfin/config:/config - ./config:/config
- ../../var/lib/homelab/jellyfin/cache:/cache - ./cache:/cache
- ../../var/lib/homelab/jellyfin/media:/media:ro - ./media:/media:ro
restart: unless-stopped restart: unless-stopped
networks: networks:
- proxy-net - proxy-net