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