|
| 1 | +# SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +# See "Full Tag Listing" in https://hub.docker.com/_/microsoft-windows-servercore |
| 4 | +ARG WIN_VERSION=ltsc2025 |
| 5 | +FROM mcr.microsoft.com/windows/servercore:$WIN_VERSION AS MSYS2_download |
| 6 | + |
| 7 | +# We always download x86_64 MSYS2 installer, since our system itself is x86_64. |
| 8 | +ARG MSYS2_VERSION=20240507 |
| 9 | +ARG MSYS2_DOWNLOAD_URL=https://repo.msys2.org/distrib/x86_64/msys2-base-x86_64-${MSYS2_VERSION}.sfx.exe |
| 10 | +RUN setx /M PATH "C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%" && \ |
| 11 | + powershell -Command "Invoke-WebRequest -Uri %MSYS2_DOWNLOAD_URL% -OutFile C:/windows/temp/msys2-base.sfx.exe" && \ |
| 12 | + C:\windows\temp\msys2-base.sfx.exe x -o"C:" |
| 13 | +# NOTE: workaround for "gpg: error reading key: Connection timed out" |
| 14 | +RUN bash -l -c "exit 0" |
| 15 | +RUN bash -l -c "pacman -Syuu --noconfirm --noprogressbar" && \ |
| 16 | + bash -l -c "pacman -Syu --needed --noconfirm --noprogressbar" && \ |
| 17 | + bash -l -c "pacman -Syu --needed --noconfirm --noprogressbar" && \ |
| 18 | + bash -l -c " \ |
| 19 | + pacman -S --needed --noconfirm --noprogressbar \ |
| 20 | + mingw-w64-x86_64-cmake diffutils git m4 make patch tar p7zip curl python3 openssl gnupg2 \ |
| 21 | + mingw-w64-x86_64-gcc \ |
| 22 | + " && \ |
| 23 | + bash -l -c "git config --system core.longpaths true" && \ |
| 24 | + bash -l -c "pacman -Scc --noconfirm" && \ |
| 25 | + echo ---- [%date% %time%] Pkg install done! |
| 26 | +# NOTE: If you hang here >10 min. You may want to `zap` temp files. |
| 27 | +# ref: https://github.com/msys2/MSYS2-packages/issues/2305#issuecomment-758162640 |
| 28 | + |
| 29 | + |
| 30 | +# ---- Move to new container, to drop messy build history |
| 31 | +ARG WIN_VERSION=ltsc2025 |
| 32 | +FROM mcr.microsoft.com/windows/servercore:$WIN_VERSION |
| 33 | + |
| 34 | +COPY --from=MSYS2_download C:/msys64 C:/msys64 |
| 35 | + |
| 36 | +# Install .NET runtime for x86_64 |
| 37 | +ARG DOTNET_URL="https://download.visualstudio.microsoft.com/download/pr/cc913baa-9bce-482e-bdfc-56c4b6fafd10/e3f24f2ab2fc02b395c1b67f5193b8d1/dotnet-runtime-8.0.8-win-x64.exe" |
| 38 | +ARG DOTNET_EXE="C:/windows/temp/dotnet-runtime.exe" |
| 39 | +RUN powershell -Command "\ |
| 40 | + Invoke-WebRequest -Uri '%DOTNET_URL%' -OutFile '%DOTNET_EXE%' -ErrorAction Stop ; \ |
| 41 | + Start-Process '%DOTNET_EXE%' -Wait -ArgumentList '/install', '/quiet', '/norestart' ; \ |
| 42 | + Remove-Item '%DOTNET_EXE%'" |
| 43 | + |
| 44 | +# Install trusted signing dlib |
| 45 | +ARG TS_URL="https://www.nuget.org/api/v2/package/Microsoft.Trusted.Signing.Client/1.0.60" |
| 46 | +ARG TS_ZIP="C:/windows/temp/ts_client.zip" |
| 47 | +ARG TS_DIR="C:/Program Files/TrustedSigning" |
| 48 | +RUN powershell -Command "\ |
| 49 | + Invoke-WebRequest -Uri '%TS_URL%' -OutFile '%TS_ZIP%' -ErrorAction Stop ; \ |
| 50 | + Expand-Archive -Path '%TS_ZIP%' -DestinationPath '%TS_DIR%' -Force ; \ |
| 51 | + Remove-Item '%TS_ZIP%'" |
| 52 | + |
| 53 | +# Download Windows 11 SDK (10.0.22621.2428) and install only `signtool.exe` |
| 54 | +ARG SDK_URL="https://go.microsoft.com/fwlink/?linkid=2250105" |
| 55 | +ARG SDK_EXE="C:/windows/temp/winsdksetup.exe" |
| 56 | +RUN powershell -Command "\ |
| 57 | + Invoke-WebRequest -Uri '%SDK_URL%' -OutFile '%SDK_EXE%' -ErrorAction Stop ; \ |
| 58 | + Start-Process '%SDK_EXE%' -Wait -ArgumentList '/features OptionId.SigningTools', '/q', '/ceip off', '/norestart' ; \ |
| 59 | + setx /M PATH ('%PATH%;' + (Resolve-Path 'C:/Program Files (x86)/Windows Kits/10/bin/*/x64/')) ; \ |
| 60 | + Remove-Item '%SDK_EXE%'" |
| 61 | + |
| 62 | +# Install Visual C++ redistributables |
| 63 | +RUN powershell -Command "Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.208 -Force; Set-PSRepository -Name PSGallery -InstallationPolicy Trusted; Install-Module -Name VcRedist -SkipPublisherCheck -Force -ErrorAction Stop" |
| 64 | + |
| 65 | +# Install AWS CLI |
| 66 | +RUN msiexec.exe /i "https://awscli.amazonaws.com/AWSCLIV2.msi" /quiet /qn && \ |
| 67 | + setx /M PATH "%PATH%;C:\Program Files\Amazon\AWSCLIV2" |
| 68 | + |
| 69 | +# Install `TrustedSigning` powershell module |
| 70 | +RUN powershell -Command "Install-Module -Name TrustedSigning" |
| 71 | + |
| 72 | +# Set default environment variables and setup useful symlinks |
| 73 | +# Note that we add an entry for `buildkite-agent` here despite it not being within |
| 74 | +# the image, because we expect it to be mounted within us in the future. |
| 75 | +RUN setx /M PATH "C:\buildkite-agent\bin;C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%" && \ |
| 76 | + mklink /J C:\msys64\home\ContainerUser C:\Users\ContainerUser && \ |
| 77 | + setx /M HOME C:\msys64\home\ContainerUser |
| 78 | +WORKDIR C:/home/ContainerUser |
| 79 | + |
| 80 | +# Select the mingw64 environment: https://www.msys2.org/docs/environments/ |
| 81 | +ENV MSYSTEM=MINGW64 |
| 82 | + |
| 83 | +# Default to `bash` for interactive builds |
| 84 | +CMD ["bash"] |
0 commit comments