Git Product home page Git Product logo

ephemeral-github-runner's Introduction

A "proper" ephemeral GitHub self-hosted runner

GitHub allows for self-hosted runners to be deployed, however one of the drawbacks has been the fact that after a build there is the potential for leftovers to be present.

This recipe wraps the GitHub actions/runner into a container that launches the runner inside a QEMU-based VM, executing a single job then terminating. This VM is then repeatedly launched in a loop, so that each job is executed on a brand new VM instance. Internally, the VM downloads a copy of the actions/runner binaries on startup, registers itself as an ephemeral self-hosted runner, and waits for a job.

Organisation-level runners are not yet supported.

docker compose

There is a docker-compose-direct.yml which shows how to configure and run the runner VM in "direct" mode, which has unrestricted network access.

There is a docker-compose-proxied.yml which shows how to configure and run the runner VM in "proxied" mode which funnels external traffic through a preconfigured squid proxy container, limiting the domains the runner has access to.

GitHub Actions Runner Container

$ docker pull ghcr.io/tzarc/ephemeral-github-runner:latest

There are a handful of environment variables that are required in order to actually get the runner talking:

Environment Variable Format Description
NUM_CPUS 1 The number of CPUs to assign to the QEMU VM.
MEMORY_ALLOC 1024 The number of MB to assign to the QEMU VM.
NICE_VAL (optional) 19 The nice value to set the QEMU process to. Defaults to 0.
RUNNER_ARCH (optional) x64 The architecture of the runner to download. Accepts the arch in the release url -- x64, arm64, arm. Defaults to x64.
GITHUB_REPOSITORY owner/repo The repository to attach the self-hosted runners to.
GITHUB_TOKEN As generated by GitHub A fine-grained personal access token, with R/W Administration access to the GITHUB_REPOSITORY.
http_proxy (optional) http://squid:3128 Proxy to use for any HTTP requests.
https_proxy (optional) http://squid:3128 Proxy to use for any HTTPS requests.
no_proxy (optional) hostA,hostB Hosts to bypass for outbound HTTP[S] requests. Not recommended to be used due to inconsistency between apps using it.

Building the container

make container

This will create a tagged container called github-runner-vm:latest.

Squid Container

$ docker pull ghcr.io/tzarc/ephemeral-github-runner:latest-squid

This is a simple squid container that is used to proxy outbound HTTP[S] requests from the runner VM. It allows for configuration of allowed domains:

Environment Variable Format Description
ALLOWED_DOMAINS_LIST .domain-a.com .domain-b.com The allowed domains. Space-separated, should include leading ..
MEM_CACHE_SIZE 1024 Cache size in MB to keep resident in memory.
FILE_CACHE_SIZE 1024 Cache size in MB to keep on disk.
FILE_MAX_SIZE 1024 The maximum size MB of any one file.

Building the container

If you also want to build the squid container:

make squid-container

...which results in a tagged container called github-runner-squid:latest.

ephemeral-github-runner's People

Contributors

tzarc avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.