This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
forked from docker-library/python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-caveman-windowsservercore.template
68 lines (61 loc) · 2.34 KB
/
Dockerfile-caveman-windowsservercore.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
FROM mcr.microsoft.com/windows/servercore:%%PLACEHOLDER%%
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV PYTHON_VERSION %%PLACEHOLDER%%
ENV PYTHON_RELEASE %%PLACEHOLDER%%
RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}.amd64.msi' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
Write-Host ('Downloading {0} ...' -f $url); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $url -OutFile 'python.msi'; \
\
Write-Host 'Installing ...'; \
# https://www.python.org/download/releases/2.4/msi/
Start-Process msiexec -Wait \
-ArgumentList @( \
'/i', \
'python.msi', \
'/quiet', \
'/qn', \
'TARGETDIR=C:\Python', \
'ALLUSERS=1', \
'ADDLOCAL=DefaultFeature,Extensions,TclTk,Tools,PrependPath' \
); \
\
# 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.msi -Force; \
\
Write-Host 'Complete.'
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION %%PLACEHOLDER%%
# https://github.com/pypa/get-pip
ENV PYTHON_GET_PIP_URL %%PLACEHOLDER%%
ENV PYTHON_GET_PIP_SHA256 %%PLACEHOLDER%%
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; \
}; \
\
Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
('pip=={0}' -f $env:PYTHON_PIP_VERSION) \
; \
Remove-Item get-pip.py -Force; \
\
Write-Host 'Verifying pip install ...'; \
pip --version; \
\
Write-Host 'Complete.'
# install "virtualenv", since the vast majority of users of this image will want it
RUN pip install --no-cache-dir virtualenv
CMD ["python"]