Giter VIP home page Giter VIP logo

github-actions-runner-docker's Introduction

github-actions-runner-docker

A recipe to build and run docker containers serving a GitHub Actions self-hosted runner.

GitHub setup

  1. create a fine-grain token on GitHub with the following permissions:

    • repository access: All repositories
    • permissions:
      • repository permissions:
        • Administration: Read and write
        • Metadata: Read-only (automatically set)
      • organisation permissions:
        • Self-hosted runners: Read and write
  2. Save the token string within the TOKEN variable in the ghe-actions-docker.env file.

VM setup

  1. create a Rocky 9 VM from a VM template

  2. install docker and jq (as root):

    dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    dnf install docker-ce docker-ce-cli containerd.io jq
    
  3. create the local user gherunner (as root):

    useradd -m gherunner
    
  4. start and enable the docker service (as root):

    systemctl start docker
    systemctl enable docker
    
  5. add the gherunner user to the docker group (as root):

    usermod -G docker gherunner
    
  6. as the gherunner user, download the latest release of this repo in a writable location (i.e. /home/gherunner)

  7. set the GITHUB, TARGET and TOKEN settings as appropriate in the ghe-actions-docker.env file (further information and examples are provided in this file).

Build

To build the container image (as the gherunner user):

docker build --tag ghe-actions-runner .

Run

To run the container image (as the gherunner user):

docker compose up --scale runner=X -d

where X is the number of runners.

Deleting stuck runners

Runners should automatically clean up after themselves once stopped, but if a SIGKILL occurs, a container may get stuck in the "Offline" state. Should this happen, run the ./delete-offline-runners.sh script.

This script reads the GITHUB, TARGET and TOKEN settings from the ghe-actions-docker.env file .

Useful commands

  • docker image list - view a list of built images
  • docker container list - view a list of running containers
  • docker stop $(docker ps -a -q) - stop all running containers
  • docker rm $(docker ps -a -q) - delete all containers (running and stopped)

github-actions-runner-docker's People

Contributors

tombradford avatar

Watchers

Tom King 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.