|
| 1 | +# |
| 2 | +# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" |
| 3 | +# |
| 4 | +# PLEASE DO NOT EDIT IT DIRECTLY. |
| 5 | +# |
| 6 | + |
| 7 | +FROM mcr.microsoft.com/windows/servercore:ltsc2022 |
| 8 | + |
| 9 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
| 10 | + |
| 11 | +# https://github.com/docker-library/python/pull/557 |
| 12 | +ENV PYTHONIOENCODING UTF-8 |
| 13 | + |
| 14 | +ENV PYTHON_VERSION 3.10.0rc1 |
| 15 | +ENV PYTHON_RELEASE 3.10.0 |
| 16 | + |
| 17 | +RUN $url = ('https://www.python.org/ftp/python/{0}/python-{1}-amd64.exe' -f $env:PYTHON_RELEASE, $env:PYTHON_VERSION); \ |
| 18 | + Write-Host ('Downloading {0} ...' -f $url); \ |
| 19 | + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ |
| 20 | + Invoke-WebRequest -Uri $url -OutFile 'python.exe'; \ |
| 21 | + \ |
| 22 | + Write-Host 'Installing ...'; \ |
| 23 | +# https://docs.python.org/3/using/windows.html#installing-without-ui |
| 24 | + $exitCode = (Start-Process python.exe -Wait -NoNewWindow -PassThru \ |
| 25 | + -ArgumentList @( \ |
| 26 | + '/quiet', \ |
| 27 | + 'InstallAllUsers=1', \ |
| 28 | + 'TargetDir=C:\Python', \ |
| 29 | + 'PrependPath=1', \ |
| 30 | + 'Shortcuts=0', \ |
| 31 | + 'Include_doc=0', \ |
| 32 | + 'Include_pip=0', \ |
| 33 | + 'Include_test=0' \ |
| 34 | + ) \ |
| 35 | + ).ExitCode; \ |
| 36 | + if ($exitCode -ne 0) { \ |
| 37 | + Write-Host ('Running python installer failed with exit code: {0}' -f $exitCode); \ |
| 38 | + Get-ChildItem $env:TEMP | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 | Get-Content; \ |
| 39 | + exit $exitCode; \ |
| 40 | + } \ |
| 41 | + \ |
| 42 | +# the installer updated PATH, so we should refresh our local value |
| 43 | + $env:PATH = [Environment]::GetEnvironmentVariable('PATH', [EnvironmentVariableTarget]::Machine); \ |
| 44 | + \ |
| 45 | + Write-Host 'Verifying install ...'; \ |
| 46 | + Write-Host ' python --version'; python --version; \ |
| 47 | + \ |
| 48 | + Write-Host 'Removing ...'; \ |
| 49 | + Remove-Item python.exe -Force; \ |
| 50 | + Remove-Item $env:TEMP/Python*.log -Force; \ |
| 51 | + \ |
| 52 | + Write-Host 'Complete.' |
| 53 | + |
| 54 | +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'" |
| 55 | +ENV PYTHON_PIP_VERSION 21.2.4 |
| 56 | +# https://github.com/pypa/get-pip |
| 57 | +ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/c20b0cfd643cd4a19246ccf204e2997af70f6b21/public/get-pip.py |
| 58 | +ENV PYTHON_GET_PIP_SHA256 fa6f3fb93cce234cd4e8dd2beb54a51ab9c247653b52855a48dd44e6b21ff28b |
| 59 | + |
| 60 | +RUN Write-Host ('Downloading get-pip.py ({0}) ...' -f $env:PYTHON_GET_PIP_URL); \ |
| 61 | + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ |
| 62 | + Invoke-WebRequest -Uri $env:PYTHON_GET_PIP_URL -OutFile 'get-pip.py'; \ |
| 63 | + Write-Host ('Verifying sha256 ({0}) ...' -f $env:PYTHON_GET_PIP_SHA256); \ |
| 64 | + if ((Get-FileHash 'get-pip.py' -Algorithm sha256).Hash -ne $env:PYTHON_GET_PIP_SHA256) { \ |
| 65 | + Write-Host 'FAILED!'; \ |
| 66 | + exit 1; \ |
| 67 | + }; \ |
| 68 | + \ |
| 69 | + Write-Host ('Installing pip=={0} ...' -f $env:PYTHON_PIP_VERSION); \ |
| 70 | + python get-pip.py \ |
| 71 | + --disable-pip-version-check \ |
| 72 | + --no-cache-dir \ |
| 73 | + ('pip=={0}' -f $env:PYTHON_PIP_VERSION) \ |
| 74 | + ; \ |
| 75 | + Remove-Item get-pip.py -Force; \ |
| 76 | + \ |
| 77 | + Write-Host 'Verifying pip install ...'; \ |
| 78 | + pip --version; \ |
| 79 | + \ |
| 80 | + Write-Host 'Complete.' |
| 81 | + |
| 82 | +CMD ["python"] |
0 commit comments