Skip to content

Commit

Permalink
ci: Add a self-hosted runner
Browse files Browse the repository at this point in the history
So we can use local machines to reduce ci times
  • Loading branch information
iamsergio committed Jan 7, 2025
1 parent cb099e8 commit 8164b4b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# This file is part of KDDockWidgets.
#
# SPDX-FileCopyrightText: 2025 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# Author: Sérgio Martins <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#
# Contact KDAB at <[email protected]> for commercial licensing options.

# Docker container used by self-hosted runner

# docker build --build-arg GITHUB_RUNNER_TOKEN=<TOKEN> -t kddw_gh_runner .
# docker run -it kddw_gh_runner /home/ubuntu/actions-runner/run.sh

FROM ubuntu:24.04
MAINTAINER Sergio Martins ([email protected])

ARG GITHUB_RUNNER_TOKEN

ENV TZ=Europe/Berlin
ENV LC_CTYPE=C.UTF-8
ENV PATH=/home/ubuntu/.local/bin:$PATH

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt update -qq && apt install build-essential software-properties-common lld git cmake ninja-build vim curl wget gdebi-core libdbus-glib-1-2 \
mesa-common-dev libglu1-mesa-dev libglib2.0-dev libfontconfig \
libxkbcommon-dev mesa-utils libgl1-mesa-dev libglu1-mesa-dev \
libxkbcommon-x11-0 libssl-dev openssl unzip clang libgtk-3-dev \
time xvfb python3-pip jq sudo -y

RUN ln -s /usr/bin/python3 /usr/bin/python
RUN rm /usr/lib/python3.12/EXTERNALLY-MANAGED

# Install GitHub command-line interface (gh)
# Instructions copied from https://github.com/cli/cli/blob/trunk/docs/install_linux.md
RUN mkdir -p -m 755 /etc/apt/keyrings \
&& curl -s https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt-get update \
&& apt-get install gh -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN usermod -aG sudo ubuntu
RUN echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/ubuntu
RUN chmod 0440 /etc/sudoers.d/ubuntu

USER ubuntu
WORKDIR /home/ubuntu


# Install GitHub Actions runner
RUN mkdir actions-runner && cd actions-runner && \
curl -o actions-runner-linux-x64-2.321.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.321.0/actions-runner-linux-x64-2.321.0.tar.gz && \
echo "ba46ba7ce3a4d7236b16fbe44419fb453bc08f866b24f04d549ec89f1722a29e actions-runner-linux-x64-2.321.0.tar.gz" | shasum -a 256 -c && \
tar xzf ./actions-runner-linux-x64-2.321.0.tar.gz && ./config.sh --labels ubuntu-latest --url https://github.com/KDAB/KDDockWidgets --token $GITHUB_RUNNER_TOKEN
9 changes: 9 additions & 0 deletions .github/docker/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only

services:
github-runner:
image: kddw_gh_runner
command: /home/ubuntu/actions-runner/run.sh
restart: always

0 comments on commit 8164b4b

Please sign in to comment.