{"id":22724687,"url":"https://github.com/mutablelogic/docker-action-runner","last_synced_at":"2025-08-08T04:33:08.538Z","repository":{"id":134265005,"uuid":"411552420","full_name":"mutablelogic/docker-action-runner","owner":"mutablelogic","description":"Create a docker image which can act as a github actions runner","archived":false,"fork":false,"pushed_at":"2024-01-09T16:32:54.000Z","size":47,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-17T18:23:26.361Z","etag":null,"topics":["actions","docker","github"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mutablelogic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-09-29T06:14:18.000Z","updated_at":"2024-01-08T17:56:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"9fa7003d-10a1-439d-a741-3e1187b62785","html_url":"https://github.com/mutablelogic/docker-action-runner","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fdocker-action-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fdocker-action-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fdocker-action-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fdocker-action-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mutablelogic","download_url":"https://codeload.github.com/mutablelogic/docker-action-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229082308,"owners_count":18017251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","docker","github"],"created_at":"2024-12-10T15:07:36.931Z","updated_at":"2024-12-10T15:07:37.604Z","avatar_url":"https://github.com/mutablelogic.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docker-action-runner\n\nThis repository contains code to create a docker image for a github action runner,\nand instructions for using it. The most useful guide I found was \n[here](https://testdriven.io/blog/github-actions-docker/) and this repository is based on that.\n\nI am targetting 64-bit (arm64 and x64), my use case is\nto be able to run GitHub Actions as self-hosted action runners.  The environment that is built\ninto docker images is:\n\n  * Architecture arm64 and x64\n  * Debian Bookworm\n  * Github Action Runner 2.311.0\n  * Additional packages `git`, `gh`, `docker-compose`\n\n## Setup\n\nIn order to create the image the first time, you'll need to install docker, as per\n[this guide](https://docs.docker.com/engine/install/debian/). Then download the repository\nand build the image, assuming you are on `arm64`. The ARCH value of `arm` is also possible\nif you are on ARM 32-bit:\n\n```bash\n[bash] git clone git@github.com:mutablelogic/docker-action-runner.git\n[bash] cd docker-action-runner \u0026\u0026 RUNNER_ARCH=\"arm64\"\n[bash] docker build \\\n  --tag \"runner-image-${RUNNER_ARCH}\" \\\n  --build-arg RUNNER_VERSION=\"2.311.0\" \\\n  --build-arg RUNNER_ARCH=\"${RUNNER_ARCH}\" \\\n  -f Dockerfile-bionic .\n```\n\nRe-tag the image for uploading to docker (or whatever other registry service you're using)\nand push to that registry once you know it's worked:\n\n```bash\n[bash] RUNNER_ARCH=\"arm64\" ORGANIZATION=\"mutablelogic\" REGISTRY=\"ghcr.io/${ORGANIZATION}\" \\\n       IMAGE=\"runner-image-${RUNNER_ARCH}\" VERSION=`git describe --tags` \n[bash] echo \"Push: ${REGISTRY}/${IMAGE}:${VERSION#v}\"\n[bash] docker login \"${REGISTRY}\"\n[bash] docker tag \"${IMAGE}\" \"${REGISTRY}/${IMAGE}:${VERSION#v}\" \u0026\u0026 docker tag \"${IMAGE}\" \"${REGISTRY}/${IMAGE}:latest\"\n[bash] docker push \"${REGISTRY}/${IMAGE}:${VERSION#v}\" \u0026\u0026 docker push \"${REGISTRY}/${IMAGE}\" \u0026\u0026 docker image rm \"${IMAGE}\"\n```\n\nAt this point you would have your images in the registry ready for use. I also made the following changes on my Raspberry Pi:\n\n  * I added `cgroup_enable=memory` to the file `/boot/cmdline.txt` and rebooted, so that nomad (see below) can use the memory cgroups support. You need to reboot the \n  Raspberry Pi to make the changes take effect;\n  * I downloaded and installed `libseccomp2_2.5.1-1_armhf.deb` from [here](http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb) which fixed an issue with building the container on ARM (change `armhf` to `arm64` as necessary).\n\n## Creating a manifest\n\nIf you have a number of images with different architectures you want to combine into a\nsingle manifest, please see the __GitHub Actions__ workflow below.\n\n## Running the runner\n\nYou then have a choice of running directly with docker or using an orchestration tool like [Nomad](https://www.nomadproject.io/).\nThe environment variables you need to set in order to manage the runner environment are:\n\n  * `ORGANIZATION`: Where you're storing the runner image in the registry and the organization attached to the runner;\n  * `ACCESS_TOKEN`: Create a personal access token in GitHub [here](https://github.com/settings/tokens). The token should have `admin:org` permissions.\n  * `NAME`: The name of the runner, which is used to identify it on GitHub (optional);\n  * `LABELS`: Comma-separated labels for the runner (optional). These are in addition\n    to the existing labels `self-hosted, linux, arm` or similar;\n  * `GROUP`: The runner group. Set to 'Default' if not otherwise set.\n\n### Docker\n\nIf you're using Docker to create a runner action process, create a personal access token in GitHub [here](https://github.com/settings/tokens).\nThe token should have `admin:org` permissions. The token should be set as an environment variable `ACCESS_TOKEN`.\n\n```bash\n[bash] ORGANIZATION=\"mutablelogic\" REGISTRY=\"ghcr.io/${ORGANIZATION}\" ACCESS_TOKEN=\"XXXXXXX\"\n[bash] docker run --detach --name action-runner \\\n  --env ORGANIZATION=\"${ORGANIZATION}\" --env ACCESS_TOKEN=\"${ACCESS_TOKEN}\" \\\n  --env NAME=\"${HOSTNAME}\" --env LABELS=\"\" --env GROUP=\"\" \\\n  --volume /var/run/docker.sock:/var/run/docker.sock \\\n  \"${REGISTRY}/runner-image:latest\"\n[bash] docker logs -f action-runner\n```\n\n(If you have a previously running container, you can remove it first with `docker stop action-runner \u0026\u0026 docker rm action-runner`).\n\nWhen you see the line \"Listening for Jobs\" you can then scoot over to the GitHub Actions page to see that the runner is working. \nThe page will be `https://github.com/organizations/${ORGANIZATION}/settings/actions/runners`\n\n### Nomad\n\nHere is a typical nomad job file that will run the runner:\n\n```hcl\nvariable \"access_token\" {\n  type = string\n}\n\nvariable \"github_username\" {\n  type = string\n  default = \"djthorpe\"\n}\n\nvariable \"organization\" {\n  type = string\n  default = \"mutablelogic\"\n}\n\nvariable \"datacenters\" {\n  type = list(string)\n  default = [ \"10707\" ]\n}\n\nvariable \"image\" {\n  type = string\n  default = \"ghcr.io/mutablelogic/runner-image\"\n}\n\njob \"action-runner\" {\n  type         = \"system\"\n  datacenters  = var.datacenters\n\n  task \"runner\" {\n    driver = \"docker\"\n\n    env {\n      ORGANIZATION = var.organization\n      NAME         = node.unique.name\n      LABELS       = node.datacenter\n      ACCESS_TOKEN = var.access_token\n    }\n\n    config {\n      image       = var.image\n      auth {\n        username  = var.github_username\n        password  = var.access_token\n      }\n      privileged  = true\n      userns_mode = \"host\"\n      volumes = [\n        \"/var/run/docker.sock:/var/run/docker.sock\",\n      ]\n    }\n  }\n}\n```\n\nYou'll need to have `var.access_token`, defined elsewhere, for example you can invoke from the command line:\n\n```bash\n[bash] nomad job run \\\n  -var -var access_token=${ACCESS_TOKEN} \\\n  action-runner.hcl \n```\n\nYour configuration for Nomad may also need to be updated for docker:\n\n```hcl\nplugin \"docker\" {\n  config {\n    allow_privileged = true\n    volumes {\n      enabled = true\n    }\n  }\n}\n```\n\n## GitHub Actions to build the image\n\nFinally, you can then create a GitHub action which will build the images and a\nmanifest, which is part of this repository [here](https://github.com/mutablelogic/docker-action-runner/blob/main/.github/workflows/make-image.yaml). These images\nare currently private but you can set up your own workflow or let me know and I can\nmake the images visible to you.\n\n## References\n\nHere are some references I found useful:\n\n  * https://testdriven.io/blog/github-actions-docker/\n  * https://docs.docker.com/engine/install/ubuntu/\n  * https://github.com/myoung34/docker-github-actions-runner\n  * https://github.com/actions/runner/releases\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutablelogic%2Fdocker-action-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmutablelogic%2Fdocker-action-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutablelogic%2Fdocker-action-runner/lists"}