Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reliability and modernisation improvements #13

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM ubuntu:22.04

# set the github runner version
ARG RUNNER_VERSION="2.311.0"
ARG RUNNER_VERSION="2.317.0"

ENV TZ=Europe/Lisbon
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
Expand All @@ -27,7 +27,8 @@ RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -; \
# cd into the user directory, download and unzip the github actions runner
RUN cd /home/docker && mkdir actions-runner && cd actions-runner \
&& curl -O -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
&& tar xzf ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz \
&& rm ./actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz

# install some additional dependencies
RUN chown -R docker ~docker && /home/docker/actions-runner/bin/installdependencies.sh
Expand Down
20 changes: 15 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
version: "3.9"
secrets:
# Note: Github personal access token
# Not the token for registering self-hosted runner
github_access-token:
file: ./access-token

services:
socket:
Expand All @@ -14,15 +18,21 @@ services:
INFO: 1
SESSION: 1
CONFIGS: 1
healthcheck:
# Test on docker healthcheck endpoint
test: [ "CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:2375/v1.35/_ping" ]
interval: 10s
timeout: 10s
retries: 3
start_period: 30s
start_interval: 2s

runner:
build:
context: .
secrets:
- github_access-token
env_file: .env
environment:
DOCKER_HOST: socket:2375
ACCESS_TOKEN_FILE: /run/secrets/github_access-token

volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./access-token:/run/secrets/github_access-token:ro
10 changes: 5 additions & 5 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/bin/bash

ORGANIZATION=$ORGANIZATION
ACCESS_TOKEN=$(cat $ACCESS_TOKEN_FILE)

REG_TOKEN=$(curl -sX POST -H "Authorization: token ${ACCESS_TOKEN}" https://api.github.com/orgs/${ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)
REG_TOKEN=$(curl -sX POST -H "Authorization: token $(cat $ACCESS_TOKEN_FILE)" https://api.github.com/orgs/${ORGANIZATION}/actions/runners/registration-token | jq .token --raw-output)

cd /home/docker/actions-runner

./config.sh --url https://github.com/${ORGANIZATION} --token ${REG_TOKEN} --ephemeral
echo "Configuring ephemeral runner..."
./config.sh --url https://github.com/${ORGANIZATION} --token ${REG_TOKEN} --ephemeral --disableupdate

cleanup() {
echo "Removing runner..."
./config.sh remove --unattended --token ${REG_TOKEN}
./config.sh remove --token ${REG_TOKEN}
}

trap 'cleanup; exit 130' INT
trap 'cleanup; exit 143' TERM

echo "Beginning run script..."
./run.sh & wait $!