-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathDockerfile-windows-servercore.template
133 lines (124 loc) · 4.13 KB
/
Dockerfile-windows-servercore.template
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
{{ def is_3: env.version | startswith("3") -}}
FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }}
# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
{{ if is_3 then "" else ( -}}
# https://github.com/docker-library/python/issues/147
ENV PYTHONIOENCODING UTF-8
{{ ) end -}}
# PATH isn't actually set in the Docker image, so we have to set it from within the container
RUN $newPath = ('C:\pypy;C:\pypy\Scripts;{0}' -f $env:PATH); \
Write-Host ('Updating PATH: {0}' -f $newPath); \
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); \
Write-Host 'Complete.'
# doing this first to share cache across versions more aggressively
# install Microsoft Visual C++ Redistributable
RUN $url = 'https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe'; \
Write-Host ('Downloading {0} ...' -f $url); \
Invoke-WebRequest -Uri $url -OutFile 'vc.exe'; \
\
$sha256 = 'da66717784c192f1004e856bbcf7b3e13b7bf3ea45932c48e4c9b9a50ca80965'; \
Write-Host ('Verifying sha256 ({0}) ...' -f $sha256); \
if ((Get-FileHash vc.exe -Algorithm sha256).Hash -ne $sha256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
\
Write-Host 'Installing ...'; \
Start-Process \
-NoNewWindow \
-Wait \
-FilePath .\vc.exe \
-ArgumentList @( \
'/install', \
'/quiet', \
'/norestart' \
); \
\
Write-Host 'Removing ...'; \
Remove-Item vc.exe -Force; \
\
Write-Host 'Complete.'
# Python {{ .python.version }}
ENV PYPY_VERSION {{ .version }}
RUN $url = '{{ .arches["windows-amd64"].url }}'; \
Write-Host ('Downloading {0} ...' -f $url); \
Invoke-WebRequest -Uri $url -OutFile 'pypy.zip'; \
\
$sha256 = '{{ .arches["windows-amd64"].sha256 }}'; \
Write-Host ('Verifying sha256 ({0}) ...' -f $sha256); \
if ((Get-FileHash pypy.zip -Algorithm sha256).Hash -ne $sha256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
\
Write-Host 'Expanding ...'; \
Expand-Archive pypy.zip -DestinationPath C:\; \
\
Write-Host 'Removing ...'; \
Remove-Item pypy.zip -Force; \
\
Write-Host 'Renaming ...'; \
Rename-Item -Path C:\{{ .arches["windows-amd64"].url | rtrimstr(".zip") | split("/")[-1] }} -NewName C:\pypy; \
\
Write-Host 'Verifying install ("pypy --version") ...'; \
pypy --version; \
\
Write-Host 'Cleanup install ...'; \
Get-ChildItem \
-Path C:\pypy \
-Include @( 'test', 'tests' ) \
-Directory \
-Recurse \
| Remove-Item -Force -Recurse; \
Get-ChildItem \
-Path C:\pypy \
-Include @( '*.pyc', '*.pyo' ) \
-File \
-Recurse \
| Remove-Item -Force; \
\
Write-Host 'Complete.'
# https://github.com/pypa/get-pip
ENV PYTHON_GET_PIP_URL {{ ."get-pip".url }}
ENV PYTHON_GET_PIP_SHA256 {{ ."get-pip".sha256 }}
RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'; \
Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_GET_PIP_SHA256); \
if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $env:PYTHON_GET_PIP_SHA256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
\
$pipVersion = & pypy -c 'import ensurepip; print(ensurepip._PIP_VERSION)'; \
$setuptoolsVersion = & pypy -c 'import ensurepip; print(ensurepip._SETUPTOOLS_VERSION)'; \
\
Write-Host ('Installing "pip == {0}", "setuptools == {1}" ...' -f $pipVersion, $setuptoolsVersion); \
pypy get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
('pip == {0}' -f $pipVersion) \
('setuptools == {0}' -f $setuptoolsVersion) \
; \
Remove-Item get-pip.py -Force; \
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
\
Write-Host 'Cleanup install ...'; \
Get-ChildItem \
-Path C:\pypy \
-Include @( 'test', 'tests' ) \
-Directory \
-Recurse \
| Remove-Item -Force -Recurse; \
Get-ChildItem \
-Path C:\pypy \
-Include @( '*.pyc', '*.pyo' ) \
-File \
-Recurse \
| Remove-Item -Force; \
\
Write-Host 'Complete.'
CMD ["pypy"]