Last active
January 5, 2023 15:30
-
-
Save maedoc/27a148ff4e18a60b48d8584df6cd331e to your computer and use it in GitHub Desktop.
Spin up GH actions runners in Docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM catthehacker/ubuntu:full-latest | |
ARG runner_version=2.299.1 | |
WORKDIR /opt | |
RUN mkdir actions-runner \ | |
&& cd actions-runner \ | |
&& curl -o actions-runner-linux-x64-${runner_version}.tar.gz \ | |
-L https://github.com/actions/runner/releases/download/v${runner_version}/actions-runner-linux-x64-${runner_version}.tar.gz \ | |
&& tar xzf ./actions-runner-linux-x64-${runner_version}.tar.gz | |
ENV RUNNER_ALLOW_RUNASROOT=1 | |
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false | |
WORKDIR /opt/actions-runner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
url=$1 | |
name=$2 | |
token=$3 | |
set -eux | |
# make sure image is built | |
docker build -t runner -f gh-actions-runner.dockerfile . | |
# remove old 'tainer | |
docker rm -f $name || true | |
# create container | |
docker run -d --name $name \ | |
--privileged \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
--entrypoint /bin/bash \ | |
--restart always \ | |
runner -c 'sleep 10 && ./run.sh' | |
sleep 1 | |
docker exec $name bash -c "./config.sh --unattended --url $url --token $token --replace --name $name" | |
docker logs -f $name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment