|
| 1 | +FROM mcr.microsoft.com/windows/servercore:ltsc2022 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 Write-Host -NoNewLine "Enabling Developer Mode"; \ |
| 13 | + $Process = \ |
| 14 | + Start-Process reg.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 15 | + 'add', \ |
| 16 | + 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock', \ |
| 17 | + '/f', \ |
| 18 | + '/t', 'REG_DWORD', \ |
| 19 | + '/v', 'AllowDevelopmentWithoutDevLicense', \ |
| 20 | + '/d', '1' \ |
| 21 | + ); \ |
| 22 | + if ($Process.ExitCode -eq 0) { \ |
| 23 | + Write-Host '✓'; \ |
| 24 | + } else { \ |
| 25 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 26 | + exit 1; \ |
| 27 | + } |
| 28 | + |
| 29 | +# Enable Long Paths |
| 30 | +# RUN Write-Host -NoNewLine "Enabling Long Paths"; \ |
| 31 | +# $Process = \ |
| 32 | +# Start-Process reg.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 33 | +# 'add', \ |
| 34 | +# 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem', \ |
| 35 | +# '/f', \ |
| 36 | +# '/t', 'REG_DWORD', \ |
| 37 | +# '/v', 'LongPathsEnabled', \ |
| 38 | +# '/d' '1' \ |
| 39 | +# ); \ |
| 40 | +# if ($Process.ExitCode -eq 0) { \ |
| 41 | +# Write-Host '✓'; \ |
| 42 | +# } else { \ |
| 43 | +# Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 44 | +# exit 1; \ |
| 45 | +# } |
| 46 | + |
| 47 | +# Install Git. |
| 48 | +# See: git-[version]-[bit].exe /SAVEINF=git.inf and /? |
| 49 | +ARG GIT=https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.2/Git-2.42.0.2-64-bit.exe |
| 50 | +ARG GIT_SHA256=BD9B41641A258FD16D99BEECEC66132160331D685DFB4C714CEA2BCC78D63BDB |
| 51 | +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:GIT}); \ |
| 52 | + Invoke-WebRequest -Uri ${env:GIT} -OutFile git.exe; \ |
| 53 | + Write-Host '✓'; \ |
| 54 | + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:GIT_SHA256}); \ |
| 55 | + $Hash = Get-FileHash git.exe -Algorithm sha256; \ |
| 56 | + if ($Hash.Hash -eq ${env:GIT_SHA256}) { \ |
| 57 | + Write-Host '✓'; \ |
| 58 | + } else { \ |
| 59 | + Write-Host ('✘ ({0})' -f $Hash.Hash); \ |
| 60 | + exit 1; \ |
| 61 | + } \ |
| 62 | + Write-Host -NoNewLine 'Installing git ... '; \ |
| 63 | + $Process = \ |
| 64 | + Start-Process git.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 65 | + '/SP-', \ |
| 66 | + '/VERYSILENT', \ |
| 67 | + '/SUPPRESSMSGBOXES', \ |
| 68 | + '/NOCANCEL', \ |
| 69 | + '/NORESTART', \ |
| 70 | + '/CLOSEAPPLICATIONS', \ |
| 71 | + '/FORCECLOSEAPPLICATIONS', \ |
| 72 | + '/NOICONS', \ |
| 73 | + '/COMPONENTS="gitlfs"', \ |
| 74 | + '/EditorOption=VIM', \ |
| 75 | + '/PathOption=Cmd', \ |
| 76 | + '/SSHOption=OpenSSH', \ |
| 77 | + '/CURLOption=WinSSL', \ |
| 78 | + '/UseCredentialManager=Enabled', \ |
| 79 | + '/EnableSymlinks=Enabled', \ |
| 80 | + '/EnableFSMonitor=Enabled' \ |
| 81 | + ); \ |
| 82 | + if ($Process.ExitCode -eq 0) { \ |
| 83 | + Write-Host '✓'; \ |
| 84 | + } else { \ |
| 85 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 86 | + exit 1; \ |
| 87 | + } \ |
| 88 | + Remove-Item -Force git.exe; \ |
| 89 | + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* |
| 90 | + |
| 91 | +# Install Python |
| 92 | +ARG PY39=https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe |
| 93 | +ARG PY39_SHA256=FB3D0466F3754752CA7FD839A09FFE53375FF2C981279FD4BC23A005458F7F5D |
| 94 | +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:PY39}); \ |
| 95 | + Invoke-WebRequest -Uri ${env:PY39} -OutFile python-3.9.13-amd64.exe; \ |
| 96 | + Write-Host '✓'; \ |
| 97 | + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:PY39_SHA256});\ |
| 98 | + $Hash = Get-FileHash python-3.9.13-amd64.exe -Algorithm sha256; \ |
| 99 | + if ($Hash.Hash -eq ${env:PY39_SHA256}) { \ |
| 100 | + Write-Host '✓'; \ |
| 101 | + } else { \ |
| 102 | + Write-Host ('✘ ({0})' -f $Hash.Hash); \ |
| 103 | + exit 1; \ |
| 104 | + } \ |
| 105 | + Write-Host -NoNewLine 'Installing Python ... '; \ |
| 106 | + $Process = \ |
| 107 | + Start-Process python-3.9.13-amd64.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 108 | + 'AssociateFiles=0', \ |
| 109 | + 'Include_doc=0', \ |
| 110 | + 'Include_debug=0', \ |
| 111 | + 'Include_dev=1', \ |
| 112 | + 'Include_exe=1', \ |
| 113 | + 'Include_lib=1', \ |
| 114 | + 'Include_tcltk=0', \ |
| 115 | + 'Include_test=0', \ |
| 116 | + 'InstallAllUsers=1', \ |
| 117 | + 'InstallLauncherAllUsers=0', \ |
| 118 | + 'PrependPath=1', \ |
| 119 | + '/quiet' \ |
| 120 | + ); \ |
| 121 | + if ($Process.ExitCode -eq 0) { \ |
| 122 | + Write-Host '✓'; \ |
| 123 | + } else { \ |
| 124 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 125 | + exit 1; \ |
| 126 | + } \ |
| 127 | + Remove-Item -Force python-3.9.13-amd64.exe; \ |
| 128 | + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* |
| 129 | + |
| 130 | +# Install Visual Studio Build Tools |
| 131 | +ARG VSB=https://aka.ms/vs/17/release/vs_buildtools.exe |
| 132 | +ARG VSB_SHA256=D4E08524CB0E5BD061A24F507928D1CFB91DCE192C5E12ED964B8343FC4CDEDD |
| 133 | +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:VSB}); \ |
| 134 | + Invoke-WebRequest -Uri ${env:VSB} -OutFile vs_buildtools.exe; \ |
| 135 | + Write-Host '✓'; \ |
| 136 | + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:VSB_SHA256}); \ |
| 137 | + $Hash = Get-FileHash vs_buildtools.exe -Algorithm sha256; \ |
| 138 | + if ($Hash.Hash -eq ${env:VSB_SHA256}) { \ |
| 139 | + Write-Host '✓'; \ |
| 140 | + } else { \ |
| 141 | + Write-Host ('✘ ({0})' -f $Hash.Hash); \ |
| 142 | + } \ |
| 143 | + Write-Host -NoNewLine 'Installing Visual Studio Build Tools ... '; \ |
| 144 | + $Process = \ |
| 145 | + Start-Process vs_buildtools.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ |
| 146 | + '--quiet', \ |
| 147 | + '--wait', \ |
| 148 | + '--norestart', \ |
| 149 | + '--nocache', \ |
| 150 | + '--add', 'Microsoft.VisualStudio.Component.Windows11SDK.22000', \ |
| 151 | + '--add', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64', \ |
| 152 | + '--add', 'Microsoft.VisualStudio.Component.VC.Tools.ARM64', \ |
| 153 | + '--add', 'Microsoft.VisualStudio.Component.VC.ATL', \ |
| 154 | + '--add', 'Microsoft.VisualStudio.Component.VC.ATL.ARM64', \ |
| 155 | + '--add', 'Microsoft.VisualStudio.Component.CMake.Project', \ |
| 156 | + '--add', 'Microsoft.NetCore.Component.SDK' \ |
| 157 | + ); \ |
| 158 | + if ($Process.ExitCode -eq 0 -or $Process.ExitCode -eq 3010) { \ |
| 159 | + Write-Host '✓'; \ |
| 160 | + } else { \ |
| 161 | + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ |
| 162 | + exit 1; \ |
| 163 | + } \ |
| 164 | + Remove-Item -Force vs_buildtools.exe; \ |
| 165 | + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* |
| 166 | + |
| 167 | +# Default to powershell |
| 168 | +# FIXME: we need to grant ContainerUser the SeCreateSymbolicLinkPrivilege |
| 169 | +# privilege so that it can create symbolic links. |
| 170 | +# USER ContainerUser |
| 171 | +CMD ["powershell.exe", "-nologo", "-ExecutionPolicy", "Bypass"] |
0 commit comments