HUB
Sign inSign up
amd64-github-runner logo

avolphen/amd64-github-runner

By avolphen

•Updated about 3 hours ago

Image
0

55

avolphen/amd64-github-runner repository overview

⁠Custom GitHub Actions runner with configurable externals

⁠Introduction

You no longer need an /actions-runner entry in the root of the host file system.

The stock runner expects its externals on the host at /actions-runner/externals. This repository removes that need. The externals can now live at any absolute host path.

The repository builds a Docker image for a self-hosted GitHub Actions runner⁠. It uses a patched runner on top of the myoung34/github-runner image.

⁠Why this repository exists

A container job gets the runner externals mounted at /__e. These hold the Node.js runtimes that JavaScript actions need.

The stock runner uses its own install path as the mount source. The runner uses the Docker daemon of the host. That daemon looks up the path on the host, not in the runner container. So the host must provide /actions-runner/externals.

This fork lets you pick another host path. Inside the job container the path stays /__e.

⁠Forked runner source

The actions-runner/ submodule is a fork of actions/runner⁠. The fork is scanframe-org/actions-runner⁠.

  • Branch: externals-via-env
  • Commit: c3a2cb11bab309799230e51c9089b0dc1748eb24

Show the changes with:

git -C actions-runner diff main...
⁠What the fork changes

The fork adds the optional RUNNER_EXTERNALS_HOST_PATH environment variable.

Runner.Worker/ContainerOperationProvider.cs:

  • When set, the value becomes the host source of the externals mount.
  • The value must be a valid absolute path.
    Otherwise the job fails with an error.
  • When not set, the stock behavior stays.
  • The target in the job container stays /__e.
  • A debug line reports the runner path, host source and container target.

Runner.Worker/Handlers/StepHost.cs:

  • Paths are now matched against the mount source and the mount target.
  • So a runner path such as /actions-runner/externals/node24/bin/node is translated to /__e/node24/bin/node.
    This also works when the mount source is a custom path.
  • Path matching now respects directory boundaries. For example, /foo/bar2 no longer matches /foo/bar.
  • A debug line reports each path translation.

Runner.Worker/Handlers/NodeScriptActionHandler.cs:

  • A debug line reports the selected Node runtime. It shows the runner path and the path used for execution.

Tests:

  • ContainerOperationProviderL0.cs covers the default, the override, invalid paths and unaffected mounts.
  • StepHostL0.cs covers path translation with a custom mount source.
⁠Updating the fork

This repository pins the submodule commit. Update the submodule reference to move to another fork revision.

⁠Repository contents

  • actions-runner/: the pinned runner fork.
  • runner/Dockerfile: replaces /actions-runner in the base image with the built _layout.
  • runner/job-started.sh: runner hook, mounted into the container by build.sh.
  • build.sh: builds, publishes and runs the runner.

⁠The build script

Run ./build.sh --help for all commands.

⁠Credentials

Settings are read from a local .credentials file. The script creates a template when the file is missing. Do not commit this file.

Required:

  • GITHUB_PAT
  • GITHUB_ORG
  • GITHUB_RUNNER_NAME

Optional:

  • RUNNER_LABELS (defaults to sf-build)
  • NEXUS_REPOSITORY for the private registry
  • DOCKER_USER for Docker Hub
⁠Build commands
  • runner: builds the runner into actions-runner/_layout. It calls dev.sh and defaults to layout Release linux-x64.
  • image: builds the Docker image. It first checks that the base image tag matches src/runnerversion. It also checks that the _layout is complete.
  • build-image: runs runner and then image.
  • clean: removes build output and the _layout, _dotnetsdk and _downloads directories.

The image is tagged amd64/github-runner:<runner version>. It also gets a tag for the private registry.

⁠Registry commands
  • push and pull: use the private registry.
  • docker-push: pushes the versioned image to Docker Hub.
  • docker-latest: pushes the image to Docker Hub as latest.
⁠Externals commands

The externals are taken from the image itself. No host install of the runner is needed.

  • zip-file: exports /actions-runner/externals from the image. It writes /tmp/runner-externals.zip.
  • zip-mount: mounts the zip file at /tmp/runner-externals using fuse-zip.
  • zip-umount: unmounts it again.
⁠Run commands
  • run: runs the runner in the foreground. The runner is ephemeral and stops after one job.
  • start: runs the runner in the background. It restarts unless stopped.
  • do-run: runs zip-file, zip-mount and then run in a loop.
  • do-start: runs zip-file, zip-mount and then start.

The script picks the externals source in this order:

  1. The fuse mount at /tmp/runner-externals/externals.
  2. /tmp/runner-externals/externals when it is empty or missing. In this case /tmp/runner-externals itself is mounted.
  3. The legacy /actions-runner/externals on the host.

The chosen path is passed as RUNNER_EXTERNALS_HOST_PATH. It is mounted at the same path in the runner container. The script warns when node24/bin/node is missing there.

The runner container also gets:

  • The host Docker socket.
  • The work directory /tmp/<runner name>.
  • The job-started.sh hook.
  • DEBUG_OUTPUT=true and ACTIONS_RUNNER_DEBUG=true. So the mount diagnostics show up in the job debug output.
⁠Container commands
  • status: shows the container.
  • do-status: shows the status every second.
  • stop, kill and remove: manage the container.
  • attach: opens a Bash shell in the container.
  • exec: runs a command in the container.
  • inspect: shows RUNNER_EXTERNALS_HOST_PATH and the mounts of the container.
⁠Quick start
./build.sh runner
./build.sh image
./build.sh push
./build.sh do-start

⁠Externals path requirements

The Docker daemon creates the job container. So the externals path must exist for that daemon.

It must exist at the same absolute path in two places:

  • The runner container.
  • The file system the Docker daemon sees.

Example: /var/lib/actions-runner/externals must exist at that exact path in both. The job container still gets it at /__e.

Tag summary

Content type

Image

Digest

sha256:ddc2ffc37…

Size

954.7 MB

Last updated

about 3 hours ago

docker pull avolphen/amd64-github-runner