-
-
Notifications
You must be signed in to change notification settings - Fork 353
Dockerized self hosted runner on Linux
Shivam Mathur edited this page Mar 2, 2023
·
2 revisions
You can use this Dockerfile
to set up a Linux self-hosted runner for GitHub Actions.
FROM shivammathur/node:latest
# shivammathur/node docker images are optimized for setup-php
# These base images will also work - ubuntu:jammy, ubuntu:focal, debian:bullseye, debian:buster
ARG RUNNER_VERSION=ver
ARG RUNNER_URL=https://github.com/foo/bar
ARG RUNNER_TOKEN=tkn
RUN set -ex && apt-get update && apt-get install -y ca-certificates curl gnupg iputils-ping libicu-dev sudo --no-install-recommends
RUN adduser --disabled-password --gecos '' runner \
&& usermod -aG sudo runner \
&& mkdir -m 777 -p /home/runner \
&& sed -i 's/%sudo\s.*/%sudo ALL=(ALL:ALL) NOPASSWD : ALL/g' /etc/sudoers
USER runner
WORKDIR /home/runner
RUN sudo mkdir -p /opt/hostedtoolcache \
&& sudo chmod -R 777 /opt/hostedtoolcache
RUN sudo curl -o runner.tar.gz -sSL https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
&& sudo tar xf runner.tar.gz \
&& sudo bash ./bin/installdependencies.sh || true
CMD [ "bash", "-c", "./config.sh --url ${RUNNER_URL} --token ${RUNNER_TOKEN}; ./run.sh; sleep infinity"]
Place the above Dockerfile
in a directory and build an image.
You can find the RUNNER_VERSION
from the curl command in the runner installation instructions. Replace the <RUNNER_VERSION>
in the command below before executing.
docker build -t linuxselfhosted:0.1 --build-arg RUNNER_VERSION=<RUNNER_VERSION> .
You can find the RUNNER_URL
and RUNNER_TOKEN
from the config command in the runner installation instructions. Replace the <RUNNER_TOKEN>
in the command below before executing.
docker run -it -e RUNNER_URL=https://github.com/foo/bar -e RUNNER_TOKEN=<RUNNER_TOKEN> linuxselfhosted:0.1