fix(selfhost): keep runner temp files off docker overlay#2720
Merged
Conversation
Points TMPDIR/TMP/TEMP for the self-hosted GitHub Actions runner service at a subdirectory of its mounted runner-work volume instead of the container's plain /tmp, which lives in Docker's overlay/ containerd snapshot storage and grows the host's Docker root storage directly (invisible to volume-scoped cleanup). A one-shot runner-tmp-init service bootstraps that directory on the volume (mkdir -p + world-writable chmod) before the runner starts, gated on depends_on: condition: service_completed_successfully, so this works on a fresh deploy with no manual steps and never touches the runner image's own entrypoint. The temp-env values live in a reusable x-runner-tmp-env anchor so additional runner services in a multi-runner override follow the same pattern. Also documents why runner temp storage must stay off overlay, a copy-pasteable multi-runner override snippet, and safe Docker cleanup guidance (containers/images/build cache only, never volumes) in the self-hosting operations docs.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 3018a99 | Commit Preview URL Branch Preview URL |
Jul 03 2026, 07:57 AM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2720 +/- ##
==========================================
- Coverage 96.13% 96.03% -0.11%
==========================================
Files 241 244 +3
Lines 27033 27271 +238
Branches 9822 9909 +87
==========================================
+ Hits 25988 26189 +201
- Misses 433 457 +24
- Partials 612 625 +13 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docker-compose.ymlleftTMPDIR/TMP/TEMPunset, so CI job temp writes (language toolchain caches, build artifacts, ad hocmktempcalls) landed in the container's plain/tmp, which lives in Docker's overlay/containerd snapshot storage — not the mountedrunner-workvolume. This grows the host's Docker root storage directly and is invisible to volume-scoped cleanup, causing unbounded overlay growth, disk pressure, anddocker system dfraces against disappearing temp files under sustained CI load.runnerservice now setsTMPDIR,TMP, andTEMPto/tmp/runner/tmp— a subdirectory of the existing mountedrunner-work:/tmp/runnervolume — via a reusablex-runner-tmp-envYAML anchor.RUNNER_WORKDIRstays on the same mounted volume as before.runner-tmp-initservice (alpine:3.20,mkdir -p+ world-writablechmod) bootstraps that directory on the volume before the runner container starts, gated viadepends_on: condition: service_completed_successfully. This is idempotent (safe on everydocker compose up) and never touches the runner image's own entrypoint/registration flow — it's a pure Compose-level dependency, not an image wrapper.x-runner-tmp-envanchor.docker-compose.override.yml.exampleand the self-hosting operations docs both document that additional runner services (for higher CI throughput) must repeat this same pattern — including the YAML-anchors-don't-cross-files caveat, since an override file can't reference the base file's anchor directly.RUNNER_WORKDIRplacement, Docker socket exposure (still never mounted), or volume-pruning behavior (none introduced; the init step only creates a directory, never deletes anything).Why
Confirmed in production: runner containers wrote high-volume CI temp files into the container default
/tmp, causing Docker root storage growth and disk pressure. The live mitigation was settingTMPDIR=/tmp/runner/tmpby hand per-container; this PR makes that the shipped default so a fresh self-host deploy is correct without any manual step.Validation
npm run typecheckdocker compose --profile runners -f docker-compose.yml config --quiet(also verified with every profile active simultaneously)npm run ui:lint/npm run ui:typecheck(docs page change)test/unit/selfhost-compose-runner-tmpdir.test.ts(13 cases — volume mount,RUNNER_WORKDIR,TMPDIR/TMP/TEMPall set and pointed at mounted storage not raw/tmp, no Docker-socket mount, no volume-deleting behavior in the init step,runners-profile gating, and that the runner service actually merges thex-runner-tmp-envanchor rather than a hand-duplicated copy that could drift) andtest/unit/docs-selfhost-operations-runner-tmpdir.test.ts(6 cases — drift guard so the docs' multi-runner snippet can't silently diverge from the real compose pattern, mirroring the existingdocs-selfhost-troubleshooting-metric-names.test.tssource-of-truth-diff approach).npm run test:ci(full local gate) — 7077 tests passed, fully green.npm audit --audit-level=moderate— 0 vulnerabilities.src/**files touched by this PR, so Codecov's patch-coverage gate has nothing to measure here; the new regression tests are pure structural/parity checks againstdocker-compose.ymland the docs page.Notes
While investigating this, found that an earlier PR (#2717) had already added a different, overlapping Docker-prune script (
scripts/docker-prune.sh) without noticingscripts/selfhost-docker-prune.sh(systemd-timer-integrated, docs-referenced, tested) already existed from PR #2576. That's an unrelated cleanup item, tracked separately — not addressed in this PR to keep it focused on the runner-tmpdir fix.