50 lines
1.7 KiB
Docker
50 lines
1.7 KiB
Docker
FROM microsoft/windowsservercore
|
|
|
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
|
|
|
|
ENV PYTHON_VERSION 3.6.0b2
|
|
ENV PYTHON_RELEASE 3.6.0
|
|
|
|
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
|
|
ENV PYTHON_PIP_VERSION 8.1.2
|
|
|
|
RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \
|
|
Write-Host ('Downloading {0} ...' -f $url); \
|
|
(New-Object System.Net.WebClient).DownloadFile($url, 'python.exe'); \
|
|
\
|
|
Write-Host 'Installing ...'; \
|
|
# https://docs.python.org/3.5/using/windows.html#installing-without-ui
|
|
Start-Process python.exe -Wait \
|
|
-ArgumentList @( \
|
|
'/quiet', \
|
|
'InstallAllUsers=1', \
|
|
'TargetDir=C:\Python', \
|
|
'PrependPath=1', \
|
|
'Shortcuts=0', \
|
|
'Include_doc=0', \
|
|
'Include_test=0' \
|
|
); \
|
|
\
|
|
# 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; \
|
|
\
|
|
$pipInstall = ('pip=={0}' -f $env:PYTHON_PIP_VERSION); \
|
|
Write-Host ('Installing {0} ...' -f $pipInstall); \
|
|
# we use "--force-reinstall" for the case where the version of pip we're trying to install is the same as the version bundled with Python
|
|
# ("Requirement already up-to-date: pip==8.1.2 in /usr/local/lib/python3.6/site-packages")
|
|
# https://github.com/docker-library/python/pull/143#issuecomment-241032683
|
|
pip install --no-cache-dir --upgrade --force-reinstall $pipInstall; \
|
|
\
|
|
Write-Host 'Verifying pip install ...'; \
|
|
pip --version; \
|
|
\
|
|
Write-Host 'Complete.';
|
|
|
|
CMD ["python"]
|