Create a Docker based Self Hosted GitHub runner Windows container

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • docker-github-runner-windows

    Repository for building a self hosted GitHub runner as a windows container

  • Open VSCode, you can clone the repo found on my GitHub project docker-github-runner-windows which contains all the files or simply follow along with the following steps. We will prepare a few PowerShell scripts that will be needed as part of our docker image creation.

  • Moby

    The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

  • #This script invokes GitHub-CLI (Already installed on container image) #To use this entrypoint script run: Docker run -e GH_TOKEN='myPatToken' -e GH_OWNER='orgName' -e GH_REPOSITORY='repoName' -d imageName Param ( [Parameter(Mandatory = $false)] [string]$owner = $env:GH_OWNER, [Parameter(Mandatory = $false)] [string]$repo = $env:GH_REPOSITORY, [Parameter(Mandatory = $false)] [string]$pat = $env:GH_TOKEN ) #Use --with-token to pass in a PAT token on standard input. The minimum required scopes for the token are: "repo", "read:org". #Alternatively, gh will use the authentication token found in environment variables. See gh help environment for more info. #To use gh in GitHub Actions, add GH_TOKEN: $ to "env". on Docker run: Docker run -e GH_TOKEN='myPatToken' gh auth login #Get Runner registration Token $jsonObj = gh api --method POST -H "Accept: application/vnd.github.v3+json" "/repos/$owner/$repo/actions/runners/registration-token" $regToken = (ConvertFrom-Json -InputObject $jsonObj).token $runnerBaseName = "dockerNode-" $runnerName = $runnerBaseName + (((New-Guid).Guid).replace("-", "")).substring(0, 5) try { #Register new runner instance write-host "Registering GitHub Self Hosted Runner on: $owner/$repo" ./config.cmd --unattended --url "https://github.com/$owner/$repo" --token $regToken --name $runnerName #Remove PAT token after registering new instance $pat=$null $env:GH_TOKEN=$null #Start runner listener for jobs ./run.cmd } catch { Write-Error $_.Exception.Message } finally { # Trap signal with finally - cleanup (When docker container is stopped remove runner registration from GitHub) # Does not currently work due to issue: https://github.com/moby/moby/issues/25982# # Perform manual cleanup of stale runners using Cleanup-Runners.ps1 ./config.cmd remove --unattended --token $regToken }

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • runner

    The Runner for GitHub Actions :rocket:

  • ##### BASE IMAGE INFO ###### #Using servercore insider edition for compacted size. #For compatibility on "your" host running docker you may need to use a specific tag. #E.g. the host OS version must match the container OS version. #If you want to run a container based on a newer Windows build, make sure you have an equivalent host build. #Otherwise, you can use Hyper-V isolation to run older containers on new host builds. #The default entrypoint is for this image is Cmd.exe. To run the image: #docker run mcr.microsoft.com/windows/servercore/insider:10.0.{build}.{revision} #tag reference: https://mcr.microsoft.com/en-us/product/windows/servercore/insider/tags #Win10 #FROM mcr.microsoft.com/windows/servercore/insider:10.0.19035.1 #Win11 FROM mcr.microsoft.com/windows/servercore/insider:10.0.20348.1 #input GitHub runner version argument ARG RUNNER_VERSION LABEL Author="Marcel L" LABEL Email="[email protected]" LABEL GitHub="https://github.com/Pwd9000-ML" LABEL BaseImage="servercore/insider:10.0.20348.1" LABEL RunnerVersion=${RUNNER_VERSION} SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] #Set working directory WORKDIR /actions-runner #Install chocolatey ADD scripts/Install-Choco.ps1 . RUN .\Install-Choco.ps1 -Wait; \ Remove-Item .\Install-Choco.ps1 -Force #Install Git, GitHub-CLI, Azure-CLI and PowerShell Core with Chocolatey (add more tooling if needed at build) RUN choco install -y \ git \ gh \ powershell-core \ azure-cli #Download GitHub Runner based on RUNNER_VERSION argument (Can use: Docker build --build-arg RUNNER_VERSION=x.y.z) RUN Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip" -OutFile "actions-runner.zip"; \ Expand-Archive -Path ".\\actions-runner.zip" -DestinationPath '.'; \ Remove-Item ".\\actions-runner.zip" -Force #Add GitHub runner configuration startup script ADD scripts/start.ps1 . ADD scripts/Cleanup-Runners.ps1 . ENTRYPOINT ["pwsh.exe", ".\\start.ps1"]

  • Puts Debuggerer

    Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.

  • ##### BASE IMAGE INFO ###### #Using servercore insider edition for compacted size. #For compatibility on "your" host running docker you may need to use a specific tag. #E.g. the host OS version must match the container OS version. #If you want to run a container based on a newer Windows build, make sure you have an equivalent host build. #Otherwise, you can use Hyper-V isolation to run older containers on new host builds. #The default entrypoint is for this image is Cmd.exe. To run the image: #docker run mcr.microsoft.com/windows/servercore/insider:10.0.{build}.{revision} #tag reference: https://mcr.microsoft.com/en-us/product/windows/servercore/insider/tags #Win10 #FROM mcr.microsoft.com/windows/servercore/insider:10.0.19035.1 #Win11 FROM mcr.microsoft.com/windows/servercore/insider:10.0.20348.1 #input GitHub runner version argument ARG RUNNER_VERSION LABEL Author="Marcel L" LABEL Email="[email protected]" LABEL GitHub="https://github.com/Pwd9000-ML" LABEL BaseImage="servercore/insider:10.0.20348.1" LABEL RunnerVersion=${RUNNER_VERSION} SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] #Set working directory WORKDIR /actions-runner #Install chocolatey ADD scripts/Install-Choco.ps1 . RUN .\Install-Choco.ps1 -Wait; \ Remove-Item .\Install-Choco.ps1 -Force #Install Git, GitHub-CLI, Azure-CLI and PowerShell Core with Chocolatey (add more tooling if needed at build) RUN choco install -y \ git \ gh \ powershell-core \ azure-cli #Download GitHub Runner based on RUNNER_VERSION argument (Can use: Docker build --build-arg RUNNER_VERSION=x.y.z) RUN Invoke-WebRequest -Uri "https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip" -OutFile "actions-runner.zip"; \ Expand-Archive -Path ".\\actions-runner.zip" -DestinationPath '.'; \ Remove-Item ".\\actions-runner.zip" -Force #Add GitHub runner configuration startup script ADD scripts/start.ps1 . ADD scripts/Cleanup-Runners.ps1 . ENTRYPOINT ["pwsh.exe", ".\\start.ps1"]

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Deploying flask app to Kubernetes using Minikube

    2 projects | dev.to | 31 Jan 2024
  • Refactoring GitOps repository to support both real-time and reconciliation window changes

    3 projects | dev.to | 13 Jan 2023
  • How to build and run k8s locally .

    2 projects | dev.to | 7 Jun 2021
  • Can't communicate with package repo if public subnet has no public IP

    3 projects | /r/aws | 24 Jul 2022
  • Top 5 DevOps Best Practices You Should Use

    4 projects | /r/u_bestarionsoftware | 27 Jun 2022