|
| 1 | +FROM mcr.microsoft.com/windows/servercore:ltsc2025 AS windows |
| 2 | + |
| 3 | +LABEL maintainer= "Swift Infrastructure <[email protected]>" |
| 4 | +LABEL description="Docker Container for the Swift programming language" |
| 5 | + |
| 6 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
| 7 | + |
| 8 | +ENV PYTHONIOENCODING UTF-8 |
| 9 | +ENV PYTHONUTF8=1 |
| 10 | + |
| 11 | +# Enable Developer Mode. |
| 12 | +RUN reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" |
| 13 | +# Enable Long Paths |
| 14 | +RUN reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" /t REG_DWORD /f /v "LongPathsEnabled" /d "1" |
| 15 | + |
| 16 | +# Install Git. |
| 17 | +# See: git-[version]-[bit].exe /SAVEINF=git.inf and /? |
| 18 | +ARG GIT=https://github.com/git-for-windows/git/releases/download/v2.48.1.windows.1/Git-2.48.1-64-bit.exe |
| 19 | +ARG GIT_SHA256=CE45E23275049F4B36EDD90D5FD986A1E230EFB6C511E9260A90176CE8E825DF |
| 20 | +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:GIT}); \ |
| 21 | + Invoke-WebRequest -Uri ${env:GIT} -OutFile git.exe; \ |
| 22 | + Write-Host '✓'; \ |
| 23 | + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:GIT_SHA256}); \ |
| 24 | + $Hash = Get-FileHash git.exe -Algorithm sha256; \ |
| 25 | + if ($Hash.Hash -eq ${env:GIT_SHA256}) { \ |
| 26 | + Write-Host '✓'; \ |
| 27 | + } else { \ |
| 28 | + Write-Host ('✘ ({0})' -f $Hash.Hash); \ |
| 29 | + exit 1; \ |
| 30 | + } \ |
| 31 | + Write-Host -NoNewLine 'Installing git ... '; \ |
| 32 | + $Process = \ |
| 33 | + Start-Process git.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 34 | + '/SP-', \ |
| 35 | + '/VERYSILENT', \ |
| 36 | + '/SUPPRESSMSGBOXES', \ |
| 37 | + '/NOCANCEL', \ |
| 38 | + '/NORESTART', \ |
| 39 | + '/CLOSEAPPLICATIONS', \ |
| 40 | + '/FORCECLOSEAPPLICATIONS', \ |
| 41 | + '/NOICONS', \ |
| 42 | + '/COMPONENTS="gitlfs"', \ |
| 43 | + '/EditorOption=VIM', \ |
| 44 | + '/PathOption=Cmd', \ |
| 45 | + '/SSHOption=OpenSSH', \ |
| 46 | + '/CURLOption=WinSSL', \ |
| 47 | + '/UseCredentialManager=Enabled', \ |
| 48 | + '/EnableSymlinks=Enabled', \ |
| 49 | + '/EnableFSMonitor=Enabled' \ |
| 50 | + ); \ |
| 51 | + if ($Process.ExitCode -eq 0) { \ |
| 52 | + Write-Host '✓'; \ |
| 53 | + } else { \ |
| 54 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 55 | + exit 1; \ |
| 56 | + } \ |
| 57 | + Remove-Item -Force git.exe; \ |
| 58 | + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* |
| 59 | + |
| 60 | +# Install Python |
| 61 | +ARG PY39=https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe |
| 62 | +ARG PY39_SHA256=FB3D0466F3754752CA7FD839A09FFE53375FF2C981279FD4BC23A005458F7F5D |
| 63 | +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:PY39}); \ |
| 64 | + Invoke-WebRequest -Uri ${env:PY39} -OutFile python-3.9.13-amd64.exe; \ |
| 65 | + Write-Host '✓'; \ |
| 66 | + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:PY39_SHA256});\ |
| 67 | + $Hash = Get-FileHash python-3.9.13-amd64.exe -Algorithm sha256; \ |
| 68 | + if ($Hash.Hash -eq ${env:PY39_SHA256}) { \ |
| 69 | + Write-Host '✓'; \ |
| 70 | + } else { \ |
| 71 | + Write-Host ('✘ ({0})' -f $Hash.Hash); \ |
| 72 | + exit 1; \ |
| 73 | + } \ |
| 74 | + Write-Host -NoNewLine 'Installing Python ... '; \ |
| 75 | + $Process = \ |
| 76 | + Start-Process python-3.9.13-amd64.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 77 | + 'AssociateFiles=0', \ |
| 78 | + 'Include_doc=0', \ |
| 79 | + 'Include_debug=0', \ |
| 80 | + 'Include_lib=1', \ |
| 81 | + 'Include_tcltk=0', \ |
| 82 | + 'Include_test=0', \ |
| 83 | + 'InstallAllUsers=1', \ |
| 84 | + 'InstallLauncherAllUsers=0', \ |
| 85 | + 'PrependPath=1', \ |
| 86 | + '/quiet' \ |
| 87 | + ); \ |
| 88 | + if ($Process.ExitCode -eq 0) { \ |
| 89 | + Write-Host '✓'; \ |
| 90 | + } else { \ |
| 91 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 92 | + exit 1; \ |
| 93 | + } \ |
| 94 | + Remove-Item -Force python-3.9.13-amd64.exe; \ |
| 95 | + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* |
| 96 | + |
| 97 | +# Install Visual Studio Build Tools |
| 98 | +ARG VSB=https://aka.ms/vs/17/release/vs_buildtools.exe |
| 99 | +ARG VSB_SHA256=15A2A6591B1E91B63E9909864FCBC68459EB26124B814618947215F754CD9CEE |
| 100 | +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:VSB}); \ |
| 101 | + Invoke-WebRequest -Uri ${env:VSB} -OutFile vs_buildtools.exe; \ |
| 102 | + Write-Host '✓'; \ |
| 103 | + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:VSB_SHA256}); \ |
| 104 | + $Hash = Get-FileHash vs_buildtools.exe -Algorithm sha256; \ |
| 105 | + if ($Hash.Hash -eq ${env:VSB_SHA256}) { \ |
| 106 | + Write-Host '✓'; \ |
| 107 | + } else { \ |
| 108 | + Write-Host ('✘ ({0})' -f $Hash.Hash); \ |
| 109 | + } \ |
| 110 | + Write-Host -NoNewLine 'Installing Visual Studio Build Tools ... '; \ |
| 111 | + $Process = \ |
| 112 | + Start-Process vs_buildtools.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 113 | + '--quiet', \ |
| 114 | + '--wait', \ |
| 115 | + '--norestart', \ |
| 116 | + '--nocache', \ |
| 117 | + '--add', 'Microsoft.VisualStudio.Component.Windows11SDK.26100', \ |
| 118 | + '--add', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', \ |
| 119 | + '--add', 'Microsoft.VisualStudio.Component.VC.Tools.ARM64' \ |
| 120 | + ); \ |
| 121 | + if ($Process.ExitCode -eq 0 -or $Process.ExitCode -eq 3010) { \ |
| 122 | + Write-Host '✓'; \ |
| 123 | + } else { \ |
| 124 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 125 | + exit 1; \ |
| 126 | + } \ |
| 127 | + Remove-Item -Force vs_buildtools.exe; \ |
| 128 | + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* |
| 129 | + |
| 130 | +# Install Swift toolchain. |
| 131 | +ARG SWIFT_RELEASE_METADATA=https://download.swift.org/development/windows10/latest-build.json |
| 132 | +RUN $Release = curl.exe -sL ${env:SWIFT_RELEASE_METADATA} | ConvertFrom-JSON; \ |
| 133 | + $SWIFT_URL = "\"https://download.swift.org/development/windows10/$($Release.dir)/$($Release.download)\""; \ |
| 134 | + Write-Host -NoNewLine ('Downloading {0} ... ' -f ${SWIFT_URL}); \ |
| 135 | + Invoke-WebRequest -Uri ${SWIFT_URL} -OutFile installer.exe; \ |
| 136 | + Write-Host '✓'; \ |
| 137 | + Write-Host -NoNewLine 'Installing Swift ... '; \ |
| 138 | + $Process = \ |
| 139 | + Start-Process installer.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 140 | + '/quiet', \ |
| 141 | + '/norestart' \ |
| 142 | + ); \ |
| 143 | + if ($Process.ExitCode -eq 0) { \ |
| 144 | + Write-Host '✓'; \ |
| 145 | + } else { \ |
| 146 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 147 | + exit 1; \ |
| 148 | + } \ |
| 149 | + Remove-Item -Force installer.exe; \ |
| 150 | + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* |
| 151 | + |
| 152 | +# FIXME: we should use a non-Administrator user |
| 153 | +# USER ContainerUser |
| 154 | +CMD ["powershell.exe", "-nologo", "-ExecutionPolicy", "Bypass"] |
0 commit comments