fix(gitea,gitea_runner): use relative state mounts and nix-independent runner base
- Replace ~/var/lib/homelab/<app> with ../../var/lib/homelab/<app> in gitea and gitea_runner compose files so docker compose resolves state without HOME - Remove inert HOMELAB_STATE_ROOT from gitea_runner/.env-example and update gitea_runner/README.md - Rebase gitea_runner/Dockerfile on gitea/act_runner:latest with Alpine nodejs/git/bash/coreutils, regular-file /etc/nix/nix.conf, pinned nixos/nix:2.24.12 store, and entrypoint-nix.sh auto-seed wrapper
This commit is contained in:
1 parent
d534399549
commit
45a9450526
6 files changed
+30
-23
No files matched your search
@@ -18,7 +18,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "${SSH_PORT:-2223}:22"
|
- "${SSH_PORT:-2223}:22"
|
||||||
volumes:
|
volumes:
|
||||||
- ~/var/lib/homelab/gitea:/data
|
- ../../var/lib/homelab/gitea:/data
|
||||||
networks:
|
networks:
|
||||||
- proxy-net
|
- proxy-net
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
@@ -3,6 +3,3 @@ GITEA_INSTANCE_URL=http://gitea:3000
|
|||||||
GITEA_RUNNER_TOKEN=replace-with-gitea-runner-registration-token
|
GITEA_RUNNER_TOKEN=replace-with-gitea-runner-registration-token
|
||||||
GITEA_RUNNER_NAME=homelab-runner
|
GITEA_RUNNER_NAME=homelab-runner
|
||||||
GITEA_RUNNER_LABELS=ubuntu-latest:host,nix:host
|
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
|
|
||||||
+17
-16
@@ -1,22 +1,23 @@
|
|||||||
FROM gitea/act_runner:latest AS act-runner
|
FROM nixos/nix:2.24.12 AS nix-src
|
||||||
|
RUN tar -czf /nix-seed.tar.gz -C /nix .
|
||||||
|
|
||||||
FROM nixos/nix:latest
|
FROM gitea/act_runner:latest
|
||||||
|
|
||||||
# Enable flakes and nix-command for CI workflows
|
RUN apk add --no-cache nodejs npm bash git coreutils ca-certificates
|
||||||
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
|
|
||||||
|
|
||||||
# Install Node.js (required by standard GitHub/Gitea Actions JS actions)
|
# Regular file (never a symlink into /nix/store) so nix-store volume mounts cannot break it
|
||||||
RUN nix-env -iA nixpkgs.nodejs \
|
RUN mkdir -p /etc/nix /nix && \
|
||||||
&& nix-collect-garbage -d
|
printf '%s\n' \
|
||||||
|
'sandbox = false' \
|
||||||
|
'experimental-features = nix-command flakes' \
|
||||||
|
'trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=' \
|
||||||
|
> /etc/nix/nix.conf
|
||||||
|
|
||||||
# Ensure /bin/sleep exists (required by act_runner init)
|
COPY --from=nix-src /nix /nix
|
||||||
RUN mkdir -p /bin \
|
COPY --from=nix-src /nix-seed.tar.gz /opt/nix-seed.tar.gz
|
||||||
&& ln -sf "$(command -v sleep)" /bin/sleep
|
COPY entrypoint-nix.sh /usr/local/bin/entrypoint-nix.sh
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint-nix.sh
|
||||||
|
|
||||||
# Copy static act_runner binary and entrypoint from official image
|
ENV PATH="/usr/local/bin:/nix/var/nix/profiles/default/bin:/usr/bin:/bin"
|
||||||
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/entrypoint-nix.sh"]
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/run.sh"]
|
|
||||||
@@ -6,8 +6,8 @@ Standalone `act_runner` for Gitea Actions, built with Nix (`nix-command` and `fl
|
|||||||
|
|
||||||
- **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`).
|
- **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**:
|
- **Persistent State & Nix Cache**:
|
||||||
- Runner registration and workspace state: `~/var/lib/homelab/gitea_runner:/data` (under `HOMELAB_STATE_ROOT`, default `~/var/lib/homelab`).
|
- 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.
|
- 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
|
## Configuration
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ services:
|
|||||||
- GITEA_RUNNER_NAME=${GITEA_RUNNER_NAME:-homelab-runner}
|
- GITEA_RUNNER_NAME=${GITEA_RUNNER_NAME:-homelab-runner}
|
||||||
- GITEA_RUNNER_LABELS=${GITEA_RUNNER_LABELS:-ubuntu-latest:host,nix:host}
|
- GITEA_RUNNER_LABELS=${GITEA_RUNNER_LABELS:-ubuntu-latest:host,nix:host}
|
||||||
volumes:
|
volumes:
|
||||||
- ~/var/lib/homelab/gitea_runner:/data
|
- ../../var/lib/homelab/gitea_runner:/data
|
||||||
- nix-store:/nix
|
- nix-store:/nix
|
||||||
networks:
|
networks:
|
||||||
- proxy-net
|
- 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 "$@"
|
||||||
Reference in new issue
Block a user