|
| 1 | +# Copyright (c) 2023 Ken Muse |
| 2 | +# Copyright (c) Advanced Micro Devices, Inc. All rights reserved. |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +# escape=` |
| 6 | + |
| 7 | +FROM mcr.microsoft.com/windows/servercore:ltsc2022 |
| 8 | +ARG RUNNER_OS=win |
| 9 | +ARG RUNNER_ARCH=x64 |
| 10 | +ARG RUNNER_VERSION |
| 11 | +ARG RUNNER_CONTAINER_HOOKS_VERSION=0.6.1 |
| 12 | + |
| 13 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"] |
| 14 | + |
| 15 | +WORKDIR /home/runner |
| 16 | + |
| 17 | +SHELL ["cmd", "/C"] |
| 18 | + |
| 19 | +RUN setx /M PATH "%PATH%;C:/home/runner" |
| 20 | + |
| 21 | +RUN echo $Env:PATH |
| 22 | + |
| 23 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';$ProgressPreference='silentlyContinue';"] |
| 24 | + |
| 25 | +RUN ` |
| 26 | + ############################################################################################### |
| 27 | + # Install Actions Runner |
| 28 | + # You must always install the runner, and you want the latest version to avoid the restrictions |
| 29 | + # applied to out-of-date runners. |
| 30 | + # https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/autoscaling-with-self-hosted-runners#:~:text=Warning,-Any%20updates%20released |
| 31 | + ############################################################################################### |
| 32 | + Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v${env:RUNNER_VERSION}/actions-runner-${env:RUNNER_OS}-${env:RUNNER_ARCH}-${env:RUNNER_VERSION}.zip -OutFile actions-runner.zip;` |
| 33 | + Add-Type -AssemblyName System.IO.Compression.FileSystem;` |
| 34 | + [System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner.zip', $PWD);` |
| 35 | + Remove-Item -Path actions-runner.zip -Force;` |
| 36 | + ############################################################################################### |
| 37 | + # Install Runner Container Hooks |
| 38 | + # While it is possible to include these hooks, Windows runners can't use these today. |
| 39 | + # GitHub documents that you must use Linux runners for Docker container actions, job containers, |
| 40 | + # or service containers. |
| 41 | + # See also https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idservices |
| 42 | + # and https://github.com/actions/runner/issues/904 |
| 43 | + ############################################################################################### |
| 44 | + # Invoke-WebRequest -OutFile runner-container-hooks.zip -Uri https://github.com/actions/runner-container-hooks/releases/download/v${env:RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${env:RUNNER_CONTAINER_HOOKS_VERSION}.zip;` |
| 45 | + # [System.IO.Compression.ZipFile]::ExtractToDirectory('runner-container-hooks.zip', (Join-Path -Path $PWD -ChildPath 'k8s'));` |
| 46 | + # Remove-Item -Path runner-container-hooks.zip -Force;` |
| 47 | + ############################################################################################### |
| 48 | + # Install Git Using Choco |
| 49 | + # Runners should have access to the latest version of Git and Git LFS, which we can |
| 50 | + # install using Choco. This also makes a Bash shell available on Windows for scripting. |
| 51 | + # You may want to include other tools and script engines as well. |
| 52 | + ############################################################################################### |
| 53 | + Set-ExecutionPolicy Bypass -Scope Process -Force;` |
| 54 | + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;` |
| 55 | + Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));` |
| 56 | + choco install -y git.install gh powershell-core azure-cli;` |
| 57 | + choco feature enable -n allowGlobalConfirmation;` |
| 58 | + ############################################################################################### |
| 59 | + # Install Docker CLI Using Choco |
| 60 | + # It's important to know that Windows doesn't support nested containers, so you can't |
| 61 | + # use a Docker-in-Docker on Windows. That frequently limits the value of having the |
| 62 | + # Docker CLI available on your images. |
| 63 | + ############################################################################################### |
| 64 | + choco install docker-cli docker-compose -force; |
| 65 | + |
| 66 | +# Append Git\bin to $PATH so bash.exe can be used. |
| 67 | +RUN setx /M PATH $($Env:PATH + ';C:\Program Files\Git\bin') |
| 68 | + |
| 69 | +RUN New-ItemProperty -Path "HKLM:\\SYSTEM\\CurrentControlSet\\Control\\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force |
| 70 | + |
| 71 | +# Download vswhere.exe from the official GitHub releases |
| 72 | +RUN Invoke-WebRequest -Uri "https://github.com/microsoft/vswhere/releases/download/2.8.4/vswhere.exe" -OutFile "vswhere.exe" |
| 73 | + |
| 74 | +RUN .\vswhere.exe |
| 75 | +RUN vswhere |
| 76 | +# Set the entrypoint to cmd.exe so you can run vswhere |
| 77 | + |
| 78 | +# Restore the default Windows shell for correct batch processing. |
| 79 | +SHELL ["cmd", "/S", "/C"] |
| 80 | + |
| 81 | +RUN ` |
| 82 | + # Download the Build Tools bootstrapper. |
| 83 | + curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe ` |
| 84 | + ` |
| 85 | + # Install Build Tools with the Microsoft.VisualStudio.Workload.AzureBuildTools workload, excluding workloads and components with known issues. |
| 86 | + && (start /w vs_buildtools.exe --quiet --wait --norestart --nocache ` |
| 87 | + --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools" ` |
| 88 | + --add Microsoft.VisualStudio.Workload.AzureBuildTools ` |
| 89 | + --remove Microsoft.VisualStudio.Component.Windows10SDK.10240 ` |
| 90 | + --remove Microsoft.VisualStudio.Component.Windows10SDK.10586 ` |
| 91 | + --remove Microsoft.VisualStudio.Component.Windows10SDK.14393 ` |
| 92 | + --remove Microsoft.VisualStudio.Component.Windows81SDK ` |
| 93 | + || IF "%ERRORLEVEL%"=="3010" EXIT 0) ` |
| 94 | + ` |
| 95 | + # Cleanup |
| 96 | + && del /q vs_buildtools.exe |
| 97 | + |
| 98 | +# Define the entry point for the docker container. |
| 99 | +# This entry point starts the developer command prompt and launches the PowerShell shell. |
| 100 | +RUN choco install cmake --version=3.31.0 -y --no-progress --installargs '"ADD_CMAKE_TO_PATH=System"' |
| 101 | +RUN choco install python --version=3.13.7 -y --no-progress |
| 102 | +RUN python -m pip install --upgrade certifi |
| 103 | +RUN setx SSL_CERT_FILE "C:\Users\ContainerAdministrator\AppData\Local\Programs\Python\Python310\Lib\site-packages\certifi\cacert.pem" |
| 104 | +RUN certutil -generateSSTFromWU certs.sst |
| 105 | +RUN certutil -addstore -f ROOT certs.sst |
| 106 | +RUN del certs.sst |
| 107 | +RUN choco install visualstudio2022-workload-vctools "--add Microsoft.VisualStudio.Component.ATL" -y --no-progress |
| 108 | +RUN python -m pip install setuptools |
| 109 | +RUN choco install visualstudio2022buildtools -y |
| 110 | +RUN choco install visualstudio2022community --package-parameters "--add Microsoft.VisualStudio.Workload.CoreEditor --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.DesktopDevelopmentWithC++" -y |
| 111 | +RUN choco install visualstudio2022-workload-nativedesktop -y |
| 112 | +RUN git clone https://github.com/microsoft/vcpkg.git C:\vcpkg ` |
| 113 | + && cd C:\vcpkg ` |
| 114 | + && bootstrap-vcpkg.bat ` |
| 115 | + && SETX /M PATH "C:\vcpkg;%PATH%" ` |
| 116 | + && vcpkg install zlib:x64-windows --clean-after-build ` |
| 117 | + && vcpkg remove zlib:x64-windows |
| 118 | + |
| 119 | +ENTRYPOINT ["C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat", "&&", "powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"] |
0 commit comments