CloudSnorkel / cdk-github-runners

CDK constructs for self-hosted GitHub Actions runners
https://constructs.dev/packages/@cloudsnorkel/cdk-github-runners/
Apache License 2.0
255 stars 37 forks source link

Windows runner #52

Closed kichik closed 1 year ago

RichiCoder1 commented 1 year ago

If there's any pointers here, I'd be interested in possible trying to PoC or contribute this!

kichik commented 1 year ago

Thanks @RichiCoder1 ! There are two steps required to get there. First we need a Dockerfile that defines an image including the runner, awscli, gh, and latest git. It should be named src/providers/docker-images/codebuild/linux-x64/Dockerfile. If we can get it working on arm64 and/or Fargate too, that'd be even better. That part I could really use the help as Docker refuses to build Windows images on my machine.

The second part is building this image. We can't use CodeBuild to build Windows Docker images because CodeBuild doesn't support that. I am working on adding support for AWS Image Builder to build images for Windows. It will be needed for EC2 support too as those need AMI and CodeBuild can't build them too easily. If you're interested in helping on this part too, I can push what I have to a branch. It's still very raw.

RichiCoder1 commented 1 year ago

@kichik Certainly! I know docker and windows is its own fun circus to get working, something we're currently working on which prompted this request :)

kichik commented 1 year ago

This is the Dockerfile I have for now. I was able to get it running manually. We would still need to use AWS Image Builder to build it and update CodeBuild to use it with PowerShell.

FROM mcr.microsoft.com/windows/servercore:ltsc2019

WORKDIR /tmp

# awscli
RUN msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi

# github cli
RUN curl -w "%{redirect_url}" -fsS https://github.com/cli/cli/releases/latest | powershell $X = $Input -Split '/'; $GH_VERSION = $X[-1].substring(1); \
    $ProgressPreference = 'SilentlyContinue'; \
    Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_windows_amd64.msi" -OutFile gh.msi && \
    msiexec.exe /i gh.msi && del gh.msi

# git
RUN curl -fsSL https://github.com/git-for-windows/git/releases/download/v2.37.1.windows.1/Git-2.37.1-64-bit.exe -o git-setup.exe && git-setup.exe /VERYSILENT && del git-setup.exe

# runner
ARG RUNNER_VERSION=latest
WORKDIR /actions
RUN curl -w "%{redirect_url}" -fsS https://github.com/actions/runner/releases/latest | powershell $X = $Input -Split '/'; $RUNNER_VERSION = $Env:RUNNER_VERSION; if ($RUNNER_VERSION -eq 'latest') { $RUNNER_VERSION = $X[-1].substring(1) }; \
    $ProgressPreference = 'SilentlyContinue'; \
    Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-win-x64-${RUNNER_VERSION}.zip" -OutFile actions.zip; \
    Expand-Archive actions.zip -DestinationPath . && del actions.zip
kichik commented 1 year ago

@RichiCoder1 would you be able to take a look at PR #94 and maybe even try it?

RichiCoder1 commented 1 year ago

@kichik Apologies, I just saw this 😅

kichik commented 1 year ago

@RichiCoder1 no worries. I plan to release probably this weekend, but any feedback would be appreciated even after that.