Skip to content

Commit

Permalink
Updates to fix issues with Windows Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mthalman committed Feb 6, 2025
1 parent 9e2980f commit f48f7ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
31 changes: 12 additions & 19 deletions src/nanoserver/1809/helix/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,26 @@ RUN $apiUrl = 'https://api.github.com/repos/PowerShell/PowerShell/releases/lates
Expand-Archive -Path C:\powershell.zip -DestinationPath C:\powershell; `
Remove-Item -Path C:\powershell.zip

# Download latest stable version of Python
RUN $apiUrl = 'https://api.nuget.org/v3-flatcontainer/python/index.json'; `
$response = Invoke-RestMethod -Uri $apiUrl; `
$versions = $response.versions | Where-Object { $_ -notmatch '-' } | Sort-Object { [version]$_ } -Descending; `
$latestVersion = $versions[0]; `
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/python/$latestVersion -OutFile $env:TEMP\python.zip; `
md C:\PythonTemp; `
tar -zxf $env:TEMP\python.zip -C C:\PythonTemp;


FROM mcr.microsoft.com/windows/nanoserver:1809

USER ContainerAdministrator
ENTRYPOINT C:\Windows\System32\cmd.exe

COPY --from=installer [ "C:\\powershell\\", "C:\\Program Files\\PowerShell\\" ]

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Install latest stable version of Python
RUN $apiUrl = "https://api.nuget.org/v3-flatcontainer/python/index.json"; `
$response = Invoke-RestMethod -Uri $apiUrl; `
$versions = $response.versions | Where-Object { $_ -notmatch '-' } | Sort-Object { [version]$_ } -Descending; `
$latestVersion = $versions[0]; `
curl -SL --output $env:TEMP\python.zip https://www.nuget.org/api/v2/package/python/$latestVersion; `
md C:\Python; `
md C:\PythonTemp; `
tar -zxf $env:TEMP\python.zip -C C:\PythonTemp; `
xcopy /s c:\PythonTemp\tools C:\Python; `
Remove-Item -Recurse -Force C:\PythonTemp; `
Remove-Item -Force $env:TEMP\python.zip; `
setx /M PYTHONPATH "C:\Python\Lib;C:\Python\DLLs;"

SHELL ["cmd", "/S", "/C"]
COPY --from=installer [ "C:\\PythonTemp\\tools", "C:\\Python\\" ]

ENV PATH="$PATH;C:\Program Files\PowerShell\;C:\Python;C:\python\scripts"
ENV PATH="$PATH;C:\Program Files\PowerShell\;C:\Python;C:\python\scripts" `
PYTHONPATH="C:\Python\Lib;C:\Python\DLLs;"

RUN md c:\\helixtmp && pushd c:\\helixtmp && `
python -m pip install --upgrade pip && `
Expand Down
13 changes: 7 additions & 6 deletions src/windowsservercore/ltsc2019/helix/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ USER ContainerAdministrator
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Install latest stable version of Python
RUN $apiUrl = "https://api.nuget.org/v3-flatcontainer/python/index.json"; `
RUN $apiUrl = 'https://api.nuget.org/v3-flatcontainer/python/index.json'; `
$response = Invoke-RestMethod -Uri $apiUrl; `
$versions = $response.versions | Where-Object { $_ -notmatch '-' } | Sort-Object { [version]$_ } -Descending; `
$latestVersion = $versions[0]; `
curl -SL --output $env:TEMP\python.zip https://www.nuget.org/api/v2/package/python/$latestVersion; `
Invoke-WebRequest -Uri https://www.nuget.org/api/v2/package/python/$latestVersion -OutFile $env:TEMP\python.zip; `
md C:\Python; `
md C:\PythonTemp; `
tar -zxf $env:TEMP\python.zip -C C:\PythonTemp; `
xcopy /s c:\PythonTemp\tools C:\Python; `
Remove-Item -Recurse -Force C:\PythonTemp; `
Remove-Item -Force $env:TEMP\python.zip; `
setx /M PYTHONPATH "C:\Python\Lib;C:\Python\DLLs;"
Remove-Item -Force $env:TEMP\python.zip;"
SHELL ["cmd", "/S", "/C"]
Expand All @@ -33,7 +32,9 @@ RUN md c:\\helixtmp && pushd c:\\helixtmp &&`
New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\' -Name 'corerun.exe' -Force -ErrorAction SilentlyContinue ; `
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\corerun.exe' -Value 2 -Name DumpType -Force ; `
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\corerun.exe' -Value 'C:\cores' -Name DumpFolder -Force ; `
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\corerun.exe' -Value 2 -Name DumpCount -Force && `
setx /M PATH "%PATH%;C:\Python;C:\python\scripts"
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\corerun.exe' -Value 2 -Name DumpCount -Force
ENV PATH="$PATH;C:\Python;C:\python\scripts" `
PYTHONPATH="C:\Python\Lib;C:\Python\DLLs;"
WORKDIR C:\\Work

0 comments on commit f48f7ff

Please sign in to comment.