k8s.io/kubernetes@v1.29.3/test/images/windows/powershell-helper/Dockerfile_windows (about) 1 # Copyright 2020 The Kubernetes Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 FROM mcr.microsoft.com/windows/servercore:ltsc2019 as prep 16 17 ENV PS_VERSION=6.2.7 18 ADD https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip /PowerShell/powershell.zip 19 20 RUN cd C:\PowerShell &\ 21 tar.exe -xf powershell.zip &\ 22 del powershell.zip &\ 23 mklink powershell.exe pwsh.exe 24 25 FROM mcr.microsoft.com/windows/nanoserver:1809 26 27 COPY --from=prep /PowerShell /PowerShell 28 29 # set a fixed location for the Module analysis cache 30 ENV LOCALAPPDATA="C:\Users\ContainerAdministrator\AppData\Local" \ 31 PSModuleAnalysisCachePath="C:\Users\ContainerAdministrator\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" \ 32 # Persist %PSCORE% ENV variable for user convenience 33 PSCORE="C:\PowerShell\pwsh.exe" 34 35 # use downloaded powershell 36 USER ContainerAdministrator 37 RUN setx /M PATH "C:\Powershell\;%PATH%" 38 39 # initialize powershell module cache 40 RUN powershell \ 41 -NoLogo \ 42 -NoProfile \ 43 -Command " \ 44 $stopTime = (get-date).AddMinutes(15); \ 45 $ErrorActionPreference = 'Stop' ; \ 46 $ProgressPreference = 'SilentlyContinue' ; \ 47 while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { \ 48 Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \ 49 if((get-date) -gt $stopTime) { throw 'timout expired'} \ 50 Start-Sleep -Seconds 6 ; \ 51 }"