Explore an innovative, efficient, and cost-effective approach to deploying a custom GitHub Runner that runs in a containerized Windows OS (x64) environment on a Linux system. This project leverages the robust capabilities of Vagrant VM, libvirt, and docker-compose which allows for seamless management of a Windows instance just like any Docker container. The added value here lies in the creation of a plug-and-play solution, significantly enhancing convenience, optimizing resource allocation, and integrating flawlessly with existing workflows. This strategy enriches CI/CD pipeline experiences in various dev-ops environments, providing a smooth and comprehensive approach that does not require prior knowledge of VM creation.
⭐ Don't forget to star the project if it helped you!
- docker version 24 or higher.
- docker-compose version 1.18 or higher.
For the purpose of authenticating your custom self-hosted runners, we offer two viable authentication methods:
-
Personal Access Token (
PAT
) - The Personal Access Token is a static, manually created token that provides secure access to GitHub. This offers a long-lived method of authentication (The PAT token needs Read and Write access to organization self-hosted runners). -
Registration Token (
TOKEN
) - The Registration Token is a dynamic, short-lived token generated automatically by GitHub during the creation of a new self-hosted runner. This provides a temporary but immediate method of authentication.
Note: Only one of these authentication methods is necessary. Choose the method that best fits your
- Create/Update the environmental file
.env
PAT
: Personal access token from GitHubTOKEN
: Short lived Github tokenRUNNER_URL
: The URL of the GitHub that the runner connects toRUNNERS
: Number of runnersMEMORY
: Amount of memory for the Vagrant image (in MB)CPU
: Number of CPUs for the Vagrant imageDISK_SIZE
: Disk size for the Vagrant image (in GB)
# Runner settings
PAT=<Your Personal access token>
RUNNER_URL=<runner url>
RUNNERS=1
# Vagrant image settings
MEMORY=8000 # 8GB
CPU=4
DISK_SIZE=100
# 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
- 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
- Run:
docker-compose up -d
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
The default users based on vagrant image are
- Administrator
- Username: Administrator
- Password: vagrant
- User
- Username: vagrant
- Password: vagrant