-
-
Notifications
You must be signed in to change notification settings - Fork 348
Dockerized self hosted runner on Windows
Shivam Mathur edited this page May 13, 2020
·
1 revision
You can use this Dockerfile
to setup a self hosted runner for GitHub Actions on windows
.
FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"]
ARG RUNNER_VERSION=ver
ARG RUNNER_URL=https://github.com/foo/bar
ARG RUNNER_TOKEN=tkn
RUN Invoke-WebRequest -Uri 'https://aka.ms/install-powershell.ps1' -OutFile install-powershell.ps1; ./install-powershell.ps1 -AddToPath; Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v$env:RUNNER_VERSION/actions-runner-win-x64-$env:RUNNER_VERSION.zip -OutFile runner.zip; Expand-Archive -Path $pwd/runner.zip -DestinationPath $pwd
CMD [ "pwsh", "-c", "./config.cmd --url $env:RUNNER_URL --token $env:RUNNER_TOKEN; ./run.cmd"]
Courtesy docker blog
Place the above Dockerfile
in a directory and build an image.
In the runner installation instructions you can find the RUNNER_VERSION
from the curl command. Replace the values in the command below before executing.
docker build -t winselfhosted:0.1 --build-arg RUNNER_VERSION=1.2.3 .
In the runner installation instructions you can find the RUNNER_URL
and RUNNER_TOKEN
from the config command. Replace the values in the command below before executing.
docker run -it -e RUNNER_URL=https://github.com/foo/bar -e RUNNER_TOKEN=ABCDEFGHIJKLNMOPQRSTUVWXYZABC winselfhosted:0.1