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