vaggeliskls
Posted on May 18, 2024
With ever-increasing advancements in the world of CI/CD pipelines, innovation is inevitable. Welcome to the exploration of an efficient, cost-effective, and innovative approach to deploying self hosted GitHub Runner. This runner operates in a containerized Windows OS (x64) environment on a Linux system.
The approach leverages the strengths of Vagrant VM, libvirt, and Docker Compose, allowing seamless management of a Windows instance just like any Docker container. The takeaway is the creation of a plug-and-play solution, significantly enhancing convenience, optimizing resource allocation, and integrating flawlessly with existing workflows.
For those working in various dev-ops environments, this strategy provides a smooth and comprehensive solution that does not require prior knowledge of VM creation.
This guide is built upon the https://github.com/vaggeliskls/windows-github-custom-runner
π Prerequisites
- Docker version 24 or higher
- Docker-compose version 1.18 or higher
π₯ Authentication Methods for Self-Hosted
To authenticate your custom self-hosted runners, two methods are available:
Personal Access Token (
PAT
): A static, manually created token that provides long-term and secure access to GitHub. This token requires Read and Write access to the GitHub organizationβs self-hosted runners.Registration Token (
TOKEN
): A dynamic, short-lived token that is automatically generated by GitHub when creating a new self-hosted runner. This method offers a temporary but immediate solution for authentication.
β Note: Only one of these authentication methods is needed. Choose the one that best suits your requirements.
π Deployment Guide
1) Create/Update the environmental file .env
-
PAT
: Personal access token from GitHub -
TOKEN
: Short lived Github token -
RUNNER_URL
: The URL of the GitHub that the runner connects to -
RUNNERS
: Number of runners -
MEMORY
: Amount of memory for the Vagrant image (in MB) -
CPU
: Number of CPUs for the Vagrant image -
DISK_SIZE
: Disk size for the Vagrant image (in GB)
Example with PAT
# Runner settings
PAT=<Your Personal access token>
RUNNER_URL=<runner url>
RUNNERS=1
# Vagrant image settings
MEMORY=8000 # 8GB
CPU=4
DISK_SIZE=100
Example with TOKEN
# Runner settings
TOKEN=<Your short lived acess token>
RUNNER_URL=<runner url>
RUNNERS=1
# Vagrant image settings
MEMORY=8000 # 8GB
CPU=4
DISK_SIZE=100
2) Create docker-compose.yml
version: "3.9"
services:
windows-github-runner-vm:
image: docker.io/vaggeliskls/windows-github-custom-runner:latest
env_file: .env
stdin_open: true
tty: true
privileged: true
ports:
- 3389:3389
3) Run: docker-compose up -d
π Access via Remote Desktop
For debugging purposes or testing you can always connect to the VM with remote desktop softwares.
Some software that used when developed was
- Linux:
rdesktop rdesktop <ip>:3389
or remina - MacOS: Windows remote desktop
- Windows: buildin
Remote Windows Connection
π User Login
The default users based on vagrant image are
1) Administrator
- Username: Administrator
- Password: vagrant
2) User
- Username: vagrant
- Password: vagrant
π Further Reading and Resources
Posted on May 18, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.