|
| 1 | +FROM microsoft/windowsservercore:ltsc2016 |
| 2 | + |
| 3 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
| 4 | + |
| 5 | +ENV PYTHON_VERSION 2.7.14 |
| 6 | +ENV PYTHON_RELEASE 2.7.14 |
| 7 | + |
| 8 | +RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}.amd64.msi' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \ |
| 9 | + Write-Host ('Downloading {0} ...' -f $url); \ |
| 10 | + Invoke-WebRequest -Uri $url -OutFile 'python.msi'; \ |
| 11 | + \ |
| 12 | + Write-Host 'Installing ...'; \ |
| 13 | +# https://www.python.org/download/releases/2.4/msi/ |
| 14 | + Start-Process msiexec -Wait \ |
| 15 | + -ArgumentList @( \ |
| 16 | + '/i', \ |
| 17 | + 'python.msi', \ |
| 18 | + '/quiet', \ |
| 19 | + '/qn', \ |
| 20 | + 'TARGETDIR=C:\Python', \ |
| 21 | + 'ALLUSERS=1', \ |
| 22 | + 'ADDLOCAL=DefaultFeature,Extensions,TclTk,Tools,PrependPath' \ |
| 23 | + ); \ |
| 24 | + \ |
| 25 | +# the installer updated PATH, so we should refresh our local value |
| 26 | + $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ |
| 27 | + \ |
| 28 | + Write-Host 'Verifying install ...'; \ |
| 29 | + Write-Host ' python --version'; python --version; \ |
| 30 | + \ |
| 31 | + Write-Host 'Removing ...'; \ |
| 32 | + Remove-Item python.msi -Force; \ |
| 33 | + \ |
| 34 | + Write-Host 'Complete.'; |
| 35 | + |
| 36 | +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" |
| 37 | +ENV PYTHON_PIP_VERSION 9.0.1 |
| 38 | + |
| 39 | +RUN Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \ |
| 40 | + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ |
| 41 | + Invoke-WebRequest -Uri 'https://bootstrap.pypa.io/get-pip.py' -OutFile 'get-pip.py'; \ |
| 42 | + python get-pip.py \ |
| 43 | + --disable-pip-version-check \ |
| 44 | + --no-cache-dir \ |
| 45 | + ('pip=={0}' -f $env:PYTHON_PIP_VERSION) \ |
| 46 | + ; \ |
| 47 | + Remove-Item get-pip.py -Force; \ |
| 48 | + \ |
| 49 | + Write-Host 'Verifying pip install ...'; \ |
| 50 | + pip --version; \ |
| 51 | + \ |
| 52 | + Write-Host 'Complete.'; |
| 53 | + |
| 54 | +# install "virtualenv", since the vast majority of users of this image will want it |
| 55 | +RUN pip install --no-cache-dir virtualenv |
| 56 | + |
| 57 | +CMD ["python"] |
0 commit comments