-
Start WSL 2 shell, get root privileges, update and install packages:
wsl -d Debian sudo -i apt update apt upgrade apt install nano curl git
-
Create a Docker network for all containers:
docker network create runner-net
-
Download GitLab runner:
cd /root # for Linux on Intel-based CPUs: curl -o gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 # for macOS on Intel-based CPUs: curl -o gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64 # for macOS on ARM-based CPUs: curl -o gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64 chmod 755 gitlab-runner
-
Register runner with
docker
executor:- default image for docker executor:
maven:3.9.7-eclipse-temurin-21
/root/gitlab-runner register
- default image for docker executor:
-
Register runner with
shell
executor:/root/gitlab-runner register
-
Tweak runner config:
nano /etc/gitlab-runner/config.toml
- add
network_mode = "runner-net"
to runner config, i.e.:
[[runners]] ... executor = "docker" ... [runners.docker] ... network_mode = "runner-net" # run containers in custom network
- add
-
Start the runner:
- press
Ctrl+C
to terminate the runner
/root/gitlab-runner run
- press
-
Remove everything, if the runner is not needed anymore:
rm -rf /root/gitlab-runner rm -rf /root/builds rm -rf /etc/gitlab-runner docker network rm runner-net
-
Create and run a container for hosting the servlet using Tomcat:
docker run -d --name github-runner --network runner-net -p 8081:8080 tomcat:9.0-jdk21
-
Open a shell in the container:
docker exec -it github-runner /bin/bash
-
Update and install packages:
apt update apt upgrade apt install maven curl
-
Change permissions on
/usr/local/tomcat/webapps
to world read-/writeable:chmod 777 /usr/local/tomcat/webapps
-
Create a new user for running the GitHub self-hosted runner and switch to that user:
adduser github-runner su -l github-runner
-
Install and run self-hosted runner for Linux X64 as explained in the settings of your repository (Settings → Actions → Runners)
-
To stop the runner, press
Ctrl+C
. -
If the runner is not needed anymore,
exit
the container shell and then stop and remove the container:docker stop github-runner docker rm github-runner
-
Create and run a SonarQube container:
# for Intel-based CPUs: docker run -d --name sonarqube --restart always \ --network runner-net -p 9000:9000 \ -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true \ sonarqube:10.4.1-community # for ARM-based CPUs: docker run -d --name sonarqube --restart always \ --network runner-net -p 9000:9000 \ -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true \ mwizner/sonarqube:9.4.0-community
-
Log in to SonarQube (initial credentials: admin/admin), create a new project, and adapt CI/CD config accordingly