forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test images: powershell-helper linux cache
We can cache the powershell-helper image's results into a scratch Linux image using docker buildx. This will allow us to spend less time pulling the data we need from the powershell-helper image when we need it. Additionally, docker buildx might have some issues with cross-registry images, so this will allow us to circumvent it.
- Loading branch information
1 parent
0ed8ee6
commit ac6ebc2
Showing
5 changed files
with
86 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2020 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM mcr.microsoft.com/windows/servercore:ltsc2019 as prep | ||
|
||
ENV PS_VERSION=6.2.7 | ||
ADD https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip /PowerShell/powershell.zip | ||
|
||
RUN cd C:\PowerShell &\ | ||
tar.exe -xf powershell.zip &\ | ||
del powershell.zip &\ | ||
mklink powershell.exe pwsh.exe | ||
|
||
FROM mcr.microsoft.com/windows/nanoserver:1809 | ||
|
||
COPY --from=prep /PowerShell /PowerShell | ||
|
||
# set a fixed location for the Module analysis cache | ||
ENV LOCALAPPDATA="C:\Users\ContainerAdministrator\AppData\Local" \ | ||
PSModuleAnalysisCachePath="C:\Users\ContainerAdministrator\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" \ | ||
# Persist %PSCORE% ENV variable for user convenience | ||
PSCORE="C:\PowerShell\pwsh.exe" | ||
|
||
# use downloaded powershell | ||
USER ContainerAdministrator | ||
RUN setx /M PATH "C:\Powershell\;%PATH%" | ||
|
||
# intialize powershell module cache | ||
RUN powershell \ | ||
-NoLogo \ | ||
-NoProfile \ | ||
-Command " \ | ||
$stopTime = (get-date).AddMinutes(15); \ | ||
$ErrorActionPreference = 'Stop' ; \ | ||
$ProgressPreference = 'SilentlyContinue' ; \ | ||
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { \ | ||
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; \ | ||
if((get-date) -gt $stopTime) { throw 'timout expired'} \ | ||
Start-Sleep -Seconds 6 ; \ | ||
}" |