-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Dockerfile-windows.template
74 lines (69 loc) · 2.39 KB
/
Dockerfile-windows.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
FROM mcr.microsoft.com/windows/{{ env.windowsVariant }}:{{ env.windowsRelease }}
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# https://github.com/docker-library/python/pull/557
ENV PYTHONIOENCODING UTF-8
ENV PYTHON_VERSION {{ .version }}
{{ if .checksums.windows.sha256 then ( -}}
ENV PYTHON_SHA256 {{ .checksums.windows.sha256 }}
{{ ) else "" end -}}
RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f ($env:PYTHON_VERSION -replace '[a-z]+[0-9]*$', ''), $env:PYTHON_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \
{{ if .checksums.windows.sha256 then ( -}}
\
Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_SHA256); \
if ((Get-FileHash python.exe -Algorithm sha256).Hash -ne $env:PYTHON_SHA256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
{{ ) else "" end -}}
\
Write-Host 'Installing ...'; \
# https://docs.python.org/3/using/windows.html#installing-without-ui
$exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \
-ArgumentList @( \
'/quiet', \
'InstallAllUsers=1', \
'TargetDir=C:\Python', \
'PrependPath=1', \
'Shortcuts=0', \
'Include_doc=0', \
'Include_pip=1', \
'Include_test=0' \
) \
).ExitCode; \
if ($exitCode -ne 0) { \
Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \
Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \
exit $exitCode; \
} \
\
# the installer updated PATH, so we should refresh our local value
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \
\
Write-Host 'Verifying install ...'; \
Write-Host ' python --version'; python --version; \
\
Write-Host 'Removing ...'; \
Remove-Item python.exe -Force; \
Remove-Item $env:TEMP/Python*.log -Force; \
\
$env:PYTHONDONTWRITEBYTECODE = '1'; \
{{ if .setuptools then ( -}}
\
Write-Host ('Installing setuptools and wheel ...'); \
pip install \
--disable-pip-version-check \
--no-cache-dir \
--no-compile \
'setuptools=={{ .setuptools.version }}' \
wheel \
; \
{{ ) else "" end -}}
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
\
Write-Host 'Complete.'
CMD ["python"]