-
-
Notifications
You must be signed in to change notification settings - Fork 387
Dockerized self hosted runner on Ubuntu
Shivam Mathur edited this page May 4, 2021
·
8 revisions
You can use this Dockerfile
to setup a self hosted runner for GitHub Actions on Ubuntu
.
FROM shivammathur/node:focal-slim
# ubuntu:focal and ubuntu:bionic would also work
# shivammathur/node docker images are optimised for setup-php
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.
In the runner installation instructions you can find the RUNNER_VERSION
from the curl command. Replace the values in the command below before executing.
docker build -t linuxselfhosted:0.1 --build-arg RUNNER_VERSION=1.2.3 .
In the runner installation instructions you can find the RUNNER_URL
and RUNNER_TOKEN
from the config command. Replace the values in the command below before executing.
docker run -it -e RUNNER_URL=https://github.com/foo/bar -e RUNNER_TOKEN=ABCDEFGHIJKLNMOPQRSTUVWXYZABC linuxselfhosted:0.1