From ef75865ca1615cd4f52b4ee7f880998051012463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parodi=2C=20Eugenio=20=F0=9F=8C=B6?= Date: Wed, 2 Apr 2025 13:44:00 +0100 Subject: [PATCH] chore: added dockerfile to create github runners --- tools/docker/github-runner/Dockerfile | 46 +++++++++++++++++++++++++++ tools/docker/github-runner/README.md | 25 +++++++++++++++ tools/docker/github-runner/script.sh | 13 ++++++++ 3 files changed, 84 insertions(+) create mode 100644 tools/docker/github-runner/Dockerfile create mode 100644 tools/docker/github-runner/README.md create mode 100644 tools/docker/github-runner/script.sh diff --git a/tools/docker/github-runner/Dockerfile b/tools/docker/github-runner/Dockerfile new file mode 100644 index 00000000..9f7db5c5 --- /dev/null +++ b/tools/docker/github-runner/Dockerfile @@ -0,0 +1,46 @@ +# Use the latest Ubuntu image as the base +# FROM ubuntu:latest +FROM --platform=linux/arm64 ubuntu:latest +# FROM --platform=linux/amd64 ubuntu:latest + + +# Install required dependencies +RUN apt-get update && apt-get install -y \ + sudo \ + curl wget tar \ + jq git gh \ + libicu74 \ + && apt-get clean + +RUN echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# Switch to the ubuntu user +USER ubuntu + +WORKDIR /home/ubuntu + +# x86-64 +# RUN curl -o actions-runner-linux-x64-2.323.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.323.0/actions-runner-linux-x64-2.323.0.tar.gz +# RUN echo "0dbc9bf5a58620fc52cb6cc0448abcca964a8d74b5f39773b7afcad9ab691e19 actions-runner-linux-x64-2.323.0.tar.gz" | shasum -a 256 -c + +# arm-64 +RUN curl -o actions-runner-linux-arm64-2.323.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.323.0/actions-runner-linux-arm64-2.323.0.tar.gz +RUN echo "9cb778fffd4c6d8bd74bc4110df7cb8c0122eb62fda30b389318b265d3ade538 actions-runner-linux-arm64-2.323.0.tar.gz" | shasum -a 256 -c + +RUN mv actions-runner-linux-* actions-runner-linux.tgz + +RUN mkdir -p /home/ubuntu/runner_1 + +WORKDIR /home/ubuntu/runner_1 + +RUN tar xzf ../actions-runner-linux.tgz + +# # Add this line to accept the token as a build argument +# ARG RUNNER_TOKEN +# # Use the token in the configuration step +# RUN ./config.sh --url https://github.com/ceccopierangiolieugenio/pyTermTk --token ${RUNNER_TOKEN} + +COPY script.sh script.sh +RUN sudo chmod +x script.sh + +ENTRYPOINT ["./script.sh"] diff --git a/tools/docker/github-runner/README.md b/tools/docker/github-runner/README.md new file mode 100644 index 00000000..76b56d9c --- /dev/null +++ b/tools/docker/github-runner/README.md @@ -0,0 +1,25 @@ +# Build the Docker +```bash +_GITHUB_TOKEN= +docker build --build-arg RUNNER_TOKEN=${_GITHUB_TOKEN} -t github-runner . +``` + +# Run the runner +you can spawn as many runner as you want just changing the name +```bash +_GITHUB_TOKEN= +_RUNNER_NAME=runner_X +docker run -it --rm github-runner ${_GITHUB_TOKEN} ${_RUNNER_NAME} +``` + +## note: +```bash +_GITHUB_TOKEN= +./config.sh \ + --url https://github.com/ceccopierangiolieugenio/pyTermTk \ + --work _work --replace \ + --runnergroup Default \ + --name test-sh \ + --token ${_GITHUB_TOKEN} \ + --labels "self-hosted,Linux,ARM64" +``` \ No newline at end of file diff --git a/tools/docker/github-runner/script.sh b/tools/docker/github-runner/script.sh new file mode 100644 index 00000000..313f226d --- /dev/null +++ b/tools/docker/github-runner/script.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +echo "First input: $1" +echo "Second input: $2" + +./config.sh \ + --url https://github.com/ceccopierangiolieugenio/pyTermTk \ + --work _work --replace \ + --runnergroup Default \ + --labels "self-hosted,Linux,ARM64" \ + --name $2 --token $1 + +./run.sh \ No newline at end of file