├── .github └── workflows │ └── container_build.yml ├── LICENSE ├── README.md ├── centos-actions-runner └── Dockerfile ├── common └── entrypoint.sh ├── debian-actions-runner └── Dockerfile ├── redhat-ubi8-actions-runner └── Dockerfile └── ubuntu-actions-runner └── Dockerfile /.github/workflows/container_build.yml: -------------------------------------------------------------------------------- 1 | # Build Docker container 2 | 3 | name: Container Build 4 | 5 | on: 6 | workflow_dispatch: 7 | inputs: 8 | runner_version: 9 | description: 'Runner version' 10 | required: true 11 | default: '2.287.1' 12 | 13 | jobs: 14 | build: 15 | runs-on: ubuntu-20.04 16 | 17 | strategy: 18 | matrix: 19 | os: 20 | - ubuntu 21 | - debian 22 | - redhat-ubi8 23 | 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v2 27 | 28 | - name: Container Metadata 29 | id: container_metadata 30 | uses: actions/github-script@v4 31 | with: 32 | script: | 33 | core.setOutput('container_tag', `${context.repo.owner}/${{ matrix.os }}-actions-runner:${context.sha}`); 34 | core.setOutput('datetime', new Date().toISOString()); 35 | 36 | - name: Build Container 37 | run: | 38 | docker build -f ${{ matrix.os }}-actions-runner/Dockerfile -t ghcr.io/${{ steps.container_metadata.outputs.container_tag }} \ 39 | --build-arg COMMIT_SHA=${{ github.sha }} \ 40 | --build-arg CREATED="${{ steps.container_metadata.outputs.datetime }}" \ 41 | --build-arg GH_RUNNER_VERSION="${{ github.event.inputs.runner_version }}" \ 42 | . 43 | shell: bash 44 | 45 | - name: Login GHCR.io 46 | uses: docker/login-action@v1 47 | with: 48 | registry: ghcr.io 49 | username: ${{ github.actor }} 50 | password: ${{ secrets.GITHUB_TOKEN }} 51 | 52 | - name: Publish 53 | run: | 54 | docker push ghcr.io/${{ steps.container_metadata.outputs.container_tag }} 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Peter Murray 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Container for GitHub Actions Runner 2 | 3 | [![awesome-runners](https://img.shields.io/badge/listed%20on-awesome--runners-blue.svg)](https://github.com/jonico/awesome-runners) 4 | 5 | This project will build a Docker container with the specified version of the GitHub Actions Runner installed into it. It is built off of CentOS 8 as a base by default. 6 | 7 | ## Building Container 8 | You can build this container using the following command: 9 | 10 | ```bash 11 | $ docker build -f [centos-actions-runner|ubuntu-actions-runner]/Dockerfile -t . 12 | ``` 13 | 14 | There are some configurable Build Arguments that you can pass in to modify the container build: 15 | 16 | * `BASE`: default value `centos:8` or `ubuntu-20.04` depending on the variant, but can be modified to specify an alternative base container image to start from 17 | * `GH_RUNNER_VERSION`: default value '2.273.0' but can be used to specify an alternative version of the GitHub Actions runner 18 | 19 | The Dockerfile has two lines that are hardcoded to use `yum` so you will have to ensure that you use a base container that supports yum if you change it. 20 | 21 | The GitHub Actions Runner will update itself to the latest version when it gets the first job sent to it if it is running an out of date version. The purpose of this parameter is to be able to set it to a value to test this upgrade scenario. 22 | A future version of this will access the releases endpoint to get the latest version and use that. 23 | 24 | 25 | ## Running the Container 26 | 27 | The container image supports a number of environment variables that you can pass to the container to control the registration of the self hosted runner with GitHub. 28 | 29 | When registering the runner you have three options for the type of runner that you are wanting to create, enterprise, organization or repository self-hosted runner. 30 | 31 | You need to provide one of the following environment variable URLs which allow the runner to be registered: 32 | 33 | * `RUNNER_ENTERPRISE_URL`: The url for enterprise when registering a enterprise runner; e.g. https://github.com/enterprises/ 34 | * `RUNNER_ORGANIZATION_URL`: The url for organization when registering an organization runner; e.g. https://github.com/octodemo 35 | * `RUNNER_REPOSITORY_URL`: The url for the repository when registering a repository; e.g. https://github.com/peter-murray/node-hue-api 36 | 37 | A GitHub Personal Access Token is required so that it can be used to obtain a short lived access token for the runner to register with GitHub. The permissions required on the Personal Access Token will depend upon to the use case of the token; 38 | 39 | * enterprise runner: `admin:enterprise` 40 | * organization runner: `admin:org` 41 | * repository runner: `repo` 42 | 43 | The token needs to be provided as the environment variable `GITHUB_TOKEN`. 44 | 45 | 46 | Optional environment variables: 47 | 48 | * `GITHUB_SERVER`: The url for GHES server (if not connecting to `github.com`) 49 | * `RUNNER_NAME`: The name for the runner, must be unique if not specified will use the hostname of the container. 50 | * `RUNNER_LABELS`: A comma separated list of labels to associate with the runner over the default values. e.g. `tester,container-runner,production` 51 | * `RUNNER_GROUP`: A runner group to associate the runner with in the organization or enterprise. If not specified will use the `default` group. 52 | 53 | 54 | ### Running using Docker commandline examples 55 | 56 | 1. Registering an Enterprise Runner; 57 | 58 | ```bash 59 | $ docker run -d \ 60 | -e RUNNER_ENTERPRISE_URL=https://github.com/enterprises/octodemo \ 61 | -e GITHUB_TOKEN= \ 62 | 63 | ``` 64 | 65 | 1. Registering an Organization Runner; 66 | 67 | ```bash 68 | $ docker run -d \ 69 | -e RUNNER_ORGANIZATION_URL=https://github.com/octodemo \ 70 | -e GITHUB_TOKEN= \ 71 | 72 | ``` 73 | 74 | 1. Registering an Repository Runner; 75 | 76 | ```bash 77 | $ docker run -d \ 78 | -e RUNNER_REPOSITORY_URL=https://github.com/octodemo/demo-repo \ 79 | -e GITHUB_TOKEN= \ 80 | 81 | ``` 82 | -------------------------------------------------------------------------------- /centos-actions-runner/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Centos is no longer a viable operating system, leaving here as a reference, but redhat-ubi8 image is a better replacement. 3 | # 4 | ARG BASE=centos:8 5 | FROM $BASE 6 | 7 | # You would typically obtain this latest version from an API endpoint and use that for the runner version 8 | # as the runner will self update to the latest version when it gets its first job. 9 | # The reason this is specified is so that we can test the upgrade scenarios using this Dockerfile. 10 | ARG GH_RUNNER_VERSION=2.286.1 11 | 12 | ARG COMMIT_SHA=master 13 | ARG CREATED="" 14 | 15 | ENV RUNNER_NAME="" 16 | ENV GITHUB_SERVER="" 17 | ENV GITHUB_TOKEN="" 18 | ENV RUNNER_LABELS="" 19 | ENV RUNNER_OPTIONS="" 20 | ENV RUNNER_WORK_DIRECTORY="_work" 21 | ENV RUNNER_ALLOW_RUNASROOT=false 22 | ENV AGENT_TOOLS_DIRECTORY=/opt/hostedtoolcache 23 | 24 | # Fill in your labels as appropriate here 25 | LABEL \ 26 | org.opencontainers.image.created="$CREATED" \ 27 | org.opencontainers.image.authors="Peter Murray" \ 28 | org.opencontainers.image.url=https://github.com/peter-murray/github-actions-runner-container \ 29 | org.opencontainers.image.documentation=https://github.com/peter-murray/github-actions-runner-container/README.md \ 30 | org.opencontainers.image.source=https://github.com/peter-murray/github-actions-runner-container \ 31 | org.opencontainers.image.version=$GH_RUNNER_VERSION \ 32 | org.opencontainers.image.revision=$COMMIT_SHA \ 33 | org.opencontainers.image.vendor="Peter Murray" \ 34 | org.opencontainers.image.licenses=MIT \ 35 | org.opencontainers.image.ref.name=centos-actions-runner \ 36 | org.opencontainers.image.title="GitHub Actions Runner Container - CentOS" \ 37 | org.opencontainers.image.description="GitHub Actions Runner built into a Container to provide self-hosted runners for Enterprise, Organization or Repositories" \ 38 | github_actions_version=$GH_RUNNER_VERSION 39 | 40 | # Create a user for running actions 41 | RUN useradd -m actions 42 | RUN mkdir -p /home/actions ${AGENT_TOOLS_DIRECTORY} 43 | WORKDIR /home/actions 44 | 45 | # jq is used by the runner to extract the token when registering the runner 46 | RUN curl -L -O https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 47 | && tar -zxf actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 48 | && rm -f actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 49 | && ./bin/installdependencies.sh \ 50 | && yum install jq git -y \ 51 | && yum clean all 52 | 53 | # Copy out the runsvc.sh script to the root directory for running the service 54 | RUN cp bin/runsvc.sh . && chmod +x ./runsvc.sh 55 | 56 | COPY common/entrypoint.sh . 57 | RUN chmod +x ./entrypoint.sh 58 | 59 | # Now that the OS has been updated to include required packages, update ownership and then switch to actions user 60 | RUN chown -R actions:actions /home/actions ${AGENT_TOOLS_DIRECTORY} 61 | 62 | USER actions 63 | CMD [ "./entrypoint.sh" ] 64 | -------------------------------------------------------------------------------- /common/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -eEo pipefail 3 | 4 | function error { 5 | echo "Error; $1" 6 | } 7 | 8 | function getRegistrationToken { 9 | if [[ -z GITHUB_TOKEN ]]; then 10 | error "A GITHUB_TOKEN environment variable is required to register the actions runner with the repository or organization." 11 | exit 1 12 | else 13 | # Get a short lived token to register the actions runner 14 | echo "Getting registration token for runner..." 15 | 16 | if [[ -z $SCOPE ]]; then 17 | error "Was not able to identify SCOPE for the token" 18 | exit 1 19 | fi 20 | 21 | if [[ ${SCOPE} == "enterprises" ]]; then 22 | URL_PATH="$(echo "${RUNNER_URL}" | grep / | cut -d/ -f5-)" 23 | else 24 | # Get the path to the organization or repository 25 | URL_PATH="$(echo "${RUNNER_URL}" | grep / | cut -d/ -f4-)" 26 | fi 27 | TOKEN_URL="${API_BASE}/${SCOPE}/${URL_PATH}/actions/runners/registration-token" 28 | echo "Getting Actions runner registration token from ${TOKEN_URL}" 29 | TOKEN="$(curl -X POST -fsSL -H "Authorization: token ${GITHUB_TOKEN}" ${TOKEN_URL} | jq -r .token)" 30 | fi 31 | } 32 | 33 | SCOPE="" 34 | TOKEN="" 35 | 36 | if [[ -z $GITHUB_SERVER ]]; then 37 | export API_BASE=https://api.github.com 38 | else 39 | export API_BASE="${GITHUB_SERVER}/api/v3" 40 | fi 41 | echo "Using ${API_BASE} as Base URL" 42 | 43 | if [[ -z $RUNNER_NAME ]]; then 44 | echo "Using hostname for Actions Runner Name." 45 | export RUNNER_NAME=${HOSTNAME} 46 | fi 47 | 48 | # We need to know what type of runner we are 49 | if [[ -z "${RUNNER_ENTERPRISE_URL}" && -z "${RUNNER_ORGANIZATION_URL}" && -z "${RUNNER_REPOSITORY_URL}" ]]; then 50 | error "RUNNER_ENTERPRISE_URL, RUNNER_ORGANIZATION_URL or RUNNER_REPOSITORY_URL needs to be specified when registering an Actions runner" 51 | exit 1 52 | fi 53 | 54 | # Use priority of enterprise -> organization -> repoistory if more than one specified 55 | if [[ -n ${RUNNER_ENTERPRISE_URL} ]]; then 56 | export RUNNER_URL=${RUNNER_ENTERPRISE_URL} 57 | SCOPE=enterprises 58 | elif [[ -n ${RUNNER_ORGANIZATION_URL} ]]; then 59 | export RUNNER_URL=${RUNNER_ORGANIZATION_URL} 60 | SCOPE=orgs 61 | elif [[ -n ${RUNNER_REPOSITORY_URL} ]]; then 62 | export RUNNER_URL=${RUNNER_REPOSITORY_URL} 63 | SCOPE=repos 64 | fi 65 | 66 | OPTIONS="${RUNNER_OPTIONS:-""}" 67 | # If the user has provided any runner labels add them to the config options 68 | if [[ -n ${RUNNER_LABELS} ]]; then 69 | OPTIONS="${OPTIONS} --labels ${RUNNER_LABELS}" 70 | fi 71 | 72 | # The runner group that the self-hosted runner will be registered with 73 | GROUP=${RUNNER_GROUP:-"default"} 74 | 75 | echo "Getting temporary access token for registering" 76 | getRegistrationToken 77 | 78 | echo "Configuring GitHub Actions Runner and registering" 79 | ./config.sh \ 80 | --unattended \ 81 | --url "${RUNNER_URL}" \ 82 | --token "${TOKEN}" \ 83 | --name "${RUNNER_NAME}" \ 84 | --work ${RUNNER_WORK_DIRECTORY} \ 85 | --runnergroup ${GROUP} \ 86 | $OPTIONS 87 | 88 | echo "Starting GitHub Actions Runner" 89 | env -i ./runsvc.sh 90 | 91 | # Deregister 92 | echo Cleaning up runner registration... 93 | getRegistrationToken 94 | ./config.sh remove --token "${TOKEN}" 95 | -------------------------------------------------------------------------------- /debian-actions-runner/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG VERSION=stretch-slim 2 | FROM debian:$VERSION 3 | 4 | # You would typically obtain this latest version from an API endpoint and use that for the runner version 5 | # as the runner will self update to the latest version when it gets its first job. 6 | # The reason this is specified is so that we can test the upgrade scenarios using this Dockerfile. 7 | ARG GH_RUNNER_VERSION=2.286.1 8 | 9 | ARG COMMIT_SHA=main 10 | ARG CREATED="" 11 | 12 | ENV RUNNER_NAME="" 13 | ENV GITHUB_SERVER="" 14 | ENV GITHUB_TOKEN="" 15 | ENV RUNNER_LABELS="" 16 | ENV RUNNER_OPTIONS="" 17 | ENV RUNNER_WORK_DIRECTORY="_work" 18 | ENV RUNNER_ALLOW_RUNASROOT=false 19 | ENV AGENT_TOOLS_DIRECTORY=/opt/hostedtoolcache 20 | 21 | # Fill in your labels as appropriate here 22 | LABEL \ 23 | org.opencontainers.image.created="$CREATED" \ 24 | org.opencontainers.image.authors="Peter Murray" \ 25 | org.opencontainers.image.url=https://github.com/peter-murray/github-actions-runner-container \ 26 | org.opencontainers.image.documentation=https://github.com/peter-murray/github-actions-runner-container/README.md \ 27 | org.opencontainers.image.source=https://github.com/peter-murray/github-actions-runner-container \ 28 | org.opencontainers.image.version=$GH_RUNNER_VERSION \ 29 | org.opencontainers.image.revision=$COMMIT_SHA \ 30 | org.opencontainers.image.vendor="Peter Murray" \ 31 | org.opencontainers.image.licenses=MIT \ 32 | org.opencontainers.image.ref.name=centos-actions-runner \ 33 | org.opencontainers.image.title="GitHub Actions Runner Container - Ubuntu" \ 34 | org.opencontainers.image.description="GitHub Actions Runner built into a Container to provide self-hosted runners for Enterprise, Organization or Repositories" \ 35 | github_actions_version=$GH_RUNNER_VERSION 36 | 37 | # Create a user for running actions 38 | RUN useradd -m actions 39 | RUN mkdir -p /home/actions ${AGENT_TOOLS_DIRECTORY} 40 | WORKDIR /home/actions 41 | 42 | # jq is used by the runner to extract the token when registering the runner 43 | RUN export DEBIAN_FRONTEND=noninteractive \ 44 | && apt-get update \ 45 | && apt-get install curl jq git -y \ 46 | && curl -L -O https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 47 | && tar -zxf actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 48 | && rm -f actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 49 | && ./bin/installdependencies.sh \ 50 | && apt-get clean \ 51 | && rm -rf /var/lib/apt/lists/* 52 | 53 | # Copy out the runsvc.sh script to the root directory for running the service 54 | RUN cp bin/runsvc.sh . && chmod +x ./runsvc.sh 55 | 56 | COPY common/entrypoint.sh . 57 | RUN chmod +x ./entrypoint.sh 58 | 59 | # Now that the OS has been updated to include required packages, update ownership and then switch to actions user 60 | RUN chown -R actions:actions /home/actions ${AGENT_TOOLS_DIRECTORY} 61 | 62 | USER actions 63 | CMD [ "./entrypoint.sh" ] 64 | -------------------------------------------------------------------------------- /redhat-ubi8-actions-runner/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG VERSION=latest 2 | ARG BASE=ubi8/ubi 3 | FROM registry.access.redhat.com/$BASE:$VERSION 4 | 5 | # You would typically obtain this latest version from an API endpoint and use that for the runner version 6 | # as the runner will self update to the latest version when it gets its first job. 7 | # The reason this is specified is so that we can test the upgrade scenarios using this Dockerfile. 8 | ARG GH_RUNNER_VERSION=2.286.1 9 | 10 | ARG COMMIT_SHA=main 11 | ARG CREATED="" 12 | 13 | ENV RUNNER_NAME="" 14 | ENV GITHUB_SERVER="" 15 | ENV GITHUB_TOKEN="" 16 | ENV RUNNER_LABELS="" 17 | ENV RUNNER_OPTIONS="" 18 | ENV RUNNER_WORK_DIRECTORY="_work" 19 | ENV RUNNER_ALLOW_RUNASROOT=false 20 | ENV AGENT_TOOLS_DIRECTORY=/opt/hostedtoolcache 21 | 22 | # Fill in your labels as appropriate here 23 | LABEL \ 24 | org.opencontainers.image.created="$CREATED" \ 25 | org.opencontainers.image.authors="Peter Murray" \ 26 | org.opencontainers.image.url=https://github.com/peter-murray/github-actions-runner-container \ 27 | org.opencontainers.image.documentation=https://github.com/peter-murray/github-actions-runner-container/README.md \ 28 | org.opencontainers.image.source=https://github.com/peter-murray/github-actions-runner-container \ 29 | org.opencontainers.image.version=$GH_RUNNER_VERSION \ 30 | org.opencontainers.image.revision=$COMMIT_SHA \ 31 | org.opencontainers.image.vendor="Peter Murray" \ 32 | org.opencontainers.image.licenses=MIT \ 33 | org.opencontainers.image.ref.name=centos-actions-runner \ 34 | org.opencontainers.image.title="GitHub Actions Runner Container - CentOS" \ 35 | org.opencontainers.image.description="GitHub Actions Runner built into a Container to provide self-hosted runners for Enterprise, Organization or Repositories" \ 36 | github_actions_version=$GH_RUNNER_VERSION 37 | 38 | # Create a user for running actions 39 | RUN useradd -m actions 40 | RUN mkdir -p /home/actions ${AGENT_TOOLS_DIRECTORY} 41 | WORKDIR /home/actions 42 | 43 | # jq is used by the runner to extract the token when registering the runner 44 | RUN curl -L -O https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 45 | && tar -zxf actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 46 | && rm -f actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 47 | && ./bin/installdependencies.sh \ 48 | && yum install jq git -y \ 49 | && yum clean all 50 | 51 | # Copy out the runsvc.sh script to the root directory for running the service 52 | RUN cp bin/runsvc.sh . && chmod +x ./runsvc.sh 53 | 54 | COPY common/entrypoint.sh . 55 | RUN chmod +x ./entrypoint.sh 56 | 57 | # Now that the OS has been updated to include required packages, update ownership and then switch to actions user 58 | RUN chown -R actions:actions /home/actions ${AGENT_TOOLS_DIRECTORY} 59 | 60 | USER actions 61 | CMD [ "./entrypoint.sh" ] 62 | -------------------------------------------------------------------------------- /ubuntu-actions-runner/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG VERSION=20.04 2 | FROM ubuntu:$VERSION 3 | 4 | # You would typically obtain this latest version from an API endpoint and use that for the runner version 5 | # as the runner will self update to the latest version when it gets its first job. 6 | # The reason this is specified is so that we can test the upgrade scenarios using this Dockerfile. 7 | ARG GH_RUNNER_VERSION=2.286.1 8 | 9 | ARG COMMIT_SHA=main 10 | ARG CREATED="" 11 | 12 | ENV RUNNER_NAME="" 13 | ENV GITHUB_SERVER="" 14 | ENV GITHUB_TOKEN="" 15 | ENV RUNNER_LABELS="" 16 | ENV RUNNER_OPTIONS="" 17 | ENV RUNNER_WORK_DIRECTORY="_work" 18 | ENV RUNNER_ALLOW_RUNASROOT=false 19 | ENV AGENT_TOOLS_DIRECTORY=/opt/hostedtoolcache 20 | 21 | # Fill in your labels as appropriate here 22 | LABEL \ 23 | org.opencontainers.image.created="$CREATED" \ 24 | org.opencontainers.image.authors="Peter Murray" \ 25 | org.opencontainers.image.url=https://github.com/peter-murray/github-actions-runner-container \ 26 | org.opencontainers.image.documentation=https://github.com/peter-murray/github-actions-runner-container/README.md \ 27 | org.opencontainers.image.source=https://github.com/peter-murray/github-actions-runner-container \ 28 | org.opencontainers.image.version=$GH_RUNNER_VERSION \ 29 | org.opencontainers.image.revision=$COMMIT_SHA \ 30 | org.opencontainers.image.vendor="Peter Murray" \ 31 | org.opencontainers.image.licenses=MIT \ 32 | org.opencontainers.image.ref.name=centos-actions-runner \ 33 | org.opencontainers.image.title="GitHub Actions Runner Container - Ubuntu" \ 34 | org.opencontainers.image.description="GitHub Actions Runner built into a Container to provide self-hosted runners for Enterprise, Organization or Repositories" \ 35 | github_actions_version=$GH_RUNNER_VERSION 36 | 37 | # Create a user for running actions 38 | RUN useradd -m actions 39 | RUN mkdir -p /home/actions ${AGENT_TOOLS_DIRECTORY} 40 | WORKDIR /home/actions 41 | 42 | # jq is used by the runner to extract the token when registering the runner 43 | RUN export DEBIAN_FRONTEND=noninteractive \ 44 | && apt-get update \ 45 | && apt-get install curl jq git -y \ 46 | && curl -L -O https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 47 | && tar -zxf actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 48 | && rm -f actions-runner-linux-x64-${GH_RUNNER_VERSION}.tar.gz \ 49 | && ./bin/installdependencies.sh \ 50 | && apt-get clean \ 51 | && rm -rf /var/lib/apt/lists/* 52 | 53 | # Copy out the runsvc.sh script to the root directory for running the service 54 | RUN cp bin/runsvc.sh . && chmod +x ./runsvc.sh 55 | 56 | COPY common/entrypoint.sh . 57 | RUN chmod +x ./entrypoint.sh 58 | 59 | # Now that the OS has been updated to include required packages, update ownership and then switch to actions user 60 | RUN chown -R actions:actions /home/actions ${AGENT_TOOLS_DIRECTORY} 61 | 62 | USER actions 63 | CMD [ "./entrypoint.sh" ] 64 | --------------------------------------------------------------------------------