Builds a warmed-up Docker image for our self-hosted runners.
The image builds on gh-runner-krunvm's ghcr.io/efrecon/runner-krunvm-ubuntu.
It bakes in the tools that gpsgate's CI otherwise downloads on every job, so jobs start fast.
The workflows don't change: they behave the same here and on GitHub-hosted runners.
| Tool | Where | Picked up by |
|---|---|---|
| Python 3.12 | /opt/hostedtoolcache/Python/3.12.x/x64 |
setup-python, through the .complete marker |
| .NET SDK 10 | /usr/share/dotnet |
setup-dotnet, which skips installed versions |
| pre-commit 4.6.0 | the tool cache Python | python -m pip install pre-commit==4.6.0 |
| pre-commit hook environments | ~/.cache/pre-commit |
pre-commit run |
| csharpier 1.2.5 | ~/.dotnet/pre-commit/csharpier/1.2.5 |
the gpsgate/csharpier hook |
| semgrep 1.172.0, sarif-tools 3.0.5 | ~/.venvs/semgrep |
the semgrep job of CI.yml |
Versions are build arguments in the Dockerfile, defaulting to the pins of gpsgate's workflows.
Keep them in sync when the workflows change.
The .NET installation script is pinned to a release of dotnet/install-scripts and its SHA-256, in bin/dotnet.sh.
The larger build steps are POSIX shell scripts under bin, each with -h for help.
actions/cache restores over the baked files when it has a hit, so both work together.
The csharpier hook only installs csharpier when it can't find the pinned version,
so PRE_COMMIT_HOOK_CSHARPIER_INSTALL: always still uses the baked binary.
setup-dotnet downloads a newer patch release when one exists.
setup-python uses the baked release, unless the workflow sets check-latest.
The weekly rebuild keeps the image close to the latest patches.
The image is about 2.7 GB larger than its base, uncompressed.
docker build -t github-runner .The hook environments come from a skeleton of gpsgate's .pre-commit-config.yaml.
Keep its repositories, revs and additional_dependencies in sync.
While unlikely, you can also build against a gpsgate checkout instead:
docker build -t github-runner --build-context precommit=/path/to/gpsgate-master .IMAGE and TAG select the base image, ghcr.io/efrecon/runner-krunvm-ubuntu:latest by default.
The image workflow builds on pull requests,
and pushes ghcr.io/gpsgate/github-runner:latest and :sha-<commit> from main.
It also rebuilds every Monday without cache, to pick up new base images and patch releases.
Manual runs take the tag of the base image, and push the branch name when not on main.
Point the runners at the image with -i or RUNNER_IMAGE:
./runner.sh -i ghcr.io/gpsgate/github-runner:latest ...
RUNNER_IMAGE=ghcr.io/gpsgate/github-runner:latest ./orchestrator.sh ...MegaLinter is not in the image.
Its image is several GB: it would make every runner start slower,
msb would download it again each time its tag moves, and podman storage would nest inside an OCI layer.
Instead, the image enables a read-only additional image store at /usr/lib/containers/storage.
Pre-pull MegaLinter into a podman store on the host and mount it into the runners.
In this example, /srv/megalinter-store is any host directory of your choice:
podman --root /srv/megalinter-store pull docker.io/oxsecurity/megalinter:<tag>
./runner.sh -M /srv/megalinter-store:/usr/lib/containers/storage:ro ...Podman then uses the image without pulling it. The store is read-only, so one job can't tamper with it for the next.
This is untested.
Mounting a store read-only through msb may run into fuse-overlayfs or permission problems.
Test it before relying on it.
Mounting writable directories such as ~/.cache/pre-commit from the host would also make jobs fast.
But pull request jobs could then write into a cache that later jobs execute: cache poisoning.
A baked image is immutable, and a read-only image store keeps that property.