-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathDockerfile-windows-servercore.template
More file actions
102 lines (95 loc) · 3.15 KB
/
Copy pathDockerfile-windows-servercore.template
File metadata and controls
102 lines (95 loc) · 3.15 KB
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
{{ include "shared" -}}
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 'Installing pip ...'; \
pypy -m ensurepip --default-pip; \
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
\
{{ if is_3 and minor >= 12 then "" else ( -}}
Write-Host 'Installing "wheel" (backwards compat) ...'; \
# https://github.com/docker-library/python/issues/952
# https://github.com/docker-library/python/issues/1023
pip install --disable-pip-version-check --no-cache-dir --no-compile 'wheel<0.46'; \
\
{{ ) end -}}
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"]