Skip to content

Instantly share code, notes, and snippets.

@techman83
Created January 22, 2022 06:45
Show Gist options
  • Save techman83/d0510b68b4a218b4f4f2efb15c88984e to your computer and use it in GitHub Desktop.
Save techman83/d0510b68b4a218b4f4f2efb15c88984e to your computer and use it in GitHub Desktop.
GitHub Runner Docker
RUNNER_VERSION=2.283.3
version: '3.7'
services:
runner-arm:
build:
context: .
args:
RUNNER_VERSION: $RUNNER_VERSION
dockerfile: Dockerfile.arm
environment:
TOKEN: ${GH_TOKEN}
ORG: ${GH_ORG}
NAME: ${RUNNER_NAME}
restart: always
volumes:
- /var/www/tasmota:/var/www/tasmota
runner-amd64:
build:
context: .
args:
RUNNER_VERSION: $RUNNER_VERSION
dockerfile: Dockerfile
environment:
TOKEN: ${GH_TOKEN}
ORG: ${GH_ORG}
NAME: ${RUNNER_NAME}
restart: always
volumes:
- /media/tasmota:/var/www/tasmota
FROM ubuntu:20.04
ARG RUNNER_VERSION
ENV DEBIAN_FRONTEND=noninteractive
RUN useradd -m actions
RUN apt-get -yqq update && apt-get install -yqq curl jq wget git python3 python3-pip rsync mosquitto-clients
RUN \
cd /home/actions && mkdir actions-runner && cd actions-runner \
&& wget 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
WORKDIR /home/actions/actions-runner
RUN chown -R actions ~actions && /home/actions/actions-runner/bin/installdependencies.sh
USER actions
COPY entrypoint.sh .
ENV PATH "$PATH:/home/actions/.local/bin"
ENTRYPOINT ["./entrypoint.sh"]
FROM arm64v8/ubuntu:focal
ARG RUNNER_VERSION
ENV DEBIAN_FRONTEND=noninteractive
RUN useradd -m actions
RUN apt-get -yqq update && apt-get install -yqq curl jq wget git python3 python3-pip rsync mosquitto-clients
RUN \
cd /home/actions && mkdir actions-runner && cd actions-runner \
&& wget https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-arm64-${RUNNER_VERSION}.tar.gz \
&& tar xzf ./actions-runner-linux-arm64-${RUNNER_VERSION}.tar.gz
WORKDIR /home/actions/actions-runner
RUN chown -R actions ~actions && /home/actions/actions-runner/bin/installdependencies.sh
USER actions
COPY entrypoint.sh .
ENV PATH "$PATH:/home/actions/.local/bin"
ENTRYPOINT ["./entrypoint.sh"]
#!/bin/bash
set -eEuo pipefail
trap cleanup exit
cleanup() {
./config.sh remove --token $(curl -s -X POST -H "authorization: token ${TOKEN}" "https://api.github.com/orgs/${ORG}/actions/runners/remove-token" | jq -r .token)
}
./config.sh \
--url "https://github.com/${ORG}" \
--token $(curl -s -X POST -H "authorization: token ${TOKEN}" "https://api.github.com/orgs/${ORG}/actions/runners/registration-token" | jq -r .token) \
--name "${NAME}" \
--unattended \
--labels ${NAME} \
--work _work
./run.sh
cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment