Compare commits
14
Commits
4c968752b9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
954cbc1c7f | ||
|
|
359ee51586 | ||
|
|
1981398cf3 | ||
|
|
51445d4af1 | ||
|
|
9ff2a4c714 | ||
|
|
f0b2acfda8 | ||
|
|
e8033baf9f | ||
|
|
2a33cb2aa8 | ||
|
|
8da3e16f21 | ||
|
|
60aa540797 | ||
|
|
75f2149275 | ||
|
|
45a9450526 | ||
|
|
d534399549 | ||
|
|
e42782f2f2 |
No files matched your search
@@ -1,3 +1,6 @@
|
||||
__pycache__/
|
||||
**/data/
|
||||
**/.env
|
||||
**/app.env
|
||||
.internal/
|
||||
.venv
|
||||
@@ -8,7 +8,7 @@ This repository contains the decoupled, portable application stacks managed by t
|
||||
|
||||
Each workload lives in its own top-level directory with a declarative `app.yaml` manifest (`schemaVersion: "1.0"`) and a `docker-compose.yml` baseline. Workloads attach to the shared external Docker network (`proxy-net`) and expose Traefik routing labels parameterized via runtime environment variables.
|
||||
|
||||
The root [`deployments.yaml`](deployments.yaml) serves as the authoritative workload admission registry, mapping each workload identity and its legacy webhook aliases to `~/Workloads/<app>`.
|
||||
The root [`deployments.yaml`](deployments.yaml) serves as the authoritative workload admission registry, mapping each workload identity and its aliases to `~/Workloads/<app>`.
|
||||
|
||||
---
|
||||
|
||||
@@ -27,6 +27,7 @@ docker compose --env-file .env up -d
|
||||
* **`deployments.yaml`**: Authoritative workload admission registry (`schemaVersion: "1.0"`).
|
||||
* **`gitea/`**: Self-hosted Git service and code repository.
|
||||
* **`gitea_runner/`**: Standalone Gitea Actions CI/CD runner (`act_runner`).
|
||||
* **`github_runner/`**: Ephemeral Nix-enabled GitHub Actions self-hosted runner.
|
||||
* **`snappymail/`**: Lightweight webmail client.
|
||||
* **`jellyfin/`**: Media server and streaming hub.
|
||||
* **`armonia/`**: Armonía del Ser API and operator dashboard.
|
||||
@@ -12,6 +12,10 @@ repositories:
|
||||
aliases:
|
||||
- "act_runner"
|
||||
- "runner"
|
||||
github_runner:
|
||||
path: "~/Workloads/github_runner"
|
||||
aliases:
|
||||
- "gh-runner"
|
||||
snappymail:
|
||||
path: "~/Workloads/snappymail"
|
||||
aliases:
|
||||
|
||||
@@ -18,7 +18,8 @@ services:
|
||||
ports:
|
||||
- "${SSH_PORT:-2223}:22"
|
||||
volumes:
|
||||
- ./data:/data
|
||||
- ../../var/lib/homelab/gitea:/data
|
||||
- ./robots.txt:/data/gitea/public/robots.txt:ro
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
@@ -28,6 +29,7 @@ services:
|
||||
- "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.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"
|
||||
# HTTP to HTTPS Redirect Router
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-gitea}-red.rule=Host(`${SERVICE_DOMAIN}`)"
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,5 @@
|
||||
# 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
|
||||
@@ -0,0 +1,23 @@
|
||||
FROM nixos/nix:2.24.12 AS nix-src
|
||||
RUN tar -czf /nix-seed.tar.gz -C /nix .
|
||||
|
||||
FROM gitea/act_runner:0.6.1
|
||||
|
||||
RUN apk add --no-cache nodejs npm bash git coreutils ca-certificates
|
||||
|
||||
# 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
|
||||
|
||||
ENV PATH="/usr/local/bin:/nix/var/nix/profiles/default/bin:/usr/bin:/bin"
|
||||
|
||||
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/entrypoint-nix.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` (resolves relative to `~/Workloads/gitea_runner` to `~/var/lib/homelab/gitea_runner` without requiring `HOME` or `${...}` interpolation).
|
||||
- Nix store cache: named Docker volume `nix-store:/nix` so evaluated derivations persist across rebuilds. If `/nix/var/nix/profiles/default/bin/nix` is missing or broken on an existing volume, `entrypoint-nix.sh` seeds `/nix` from `/opt/nix-seed.tar.gz`.
|
||||
|
||||
## 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}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/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
|
||||
|
||||
exec /usr/local/bin/run.sh "$@"
|
||||
@@ -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
|
||||
@@ -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"]
|
||||
@@ -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`).
|
||||
@@ -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
|
||||
@@ -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: {}
|
||||
Executable
+18
@@ -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 "$@"
|
||||
@@ -4,7 +4,7 @@ services:
|
||||
container_name: ${CONTAINER_NAME:-snappymail}
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/var/lib/snappymail/_data_
|
||||
- ../../var/lib/homelab/snappymail:/var/lib/snappymail/_data_
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
|
||||
Reference in new issue
Block a user