Skip to content

Commit 890b315

Browse files
authored
Add Windows 20H2 images (#523)
Signed-off-by: Vincent Boulineau <[email protected]>
1 parent 79ec70c commit 890b315

File tree

17 files changed

+599
-5
lines changed

17 files changed

+599
-5
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ updates:
2929
interval: "weekly"
3030

3131
- package-ecosystem: "docker"
32-
directory: "/release/preview/nanoserver2004/dependabot"
32+
directory: "/release/preview/nanoserver20H2/dependabot"
3333
schedule:
3434
interval: "weekly"
3535

release/lts/nanoserver2004/dependabot/Dockerfile renamed to release/lts/nanoserver20H2/dependabot/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
# Dummy docker image to trigger dependabot PRs
55

6-
FROM mcr.microsoft.com/windows/nanoserver:2004
6+
FROM mcr.microsoft.com/windows/nanoserver:20H2
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# escape=`
2+
# Args used by from statements must be defined here:
3+
ARG InstallerVersion=nanoserver
4+
ARG InstallerRepo=mcr.microsoft.com/powershell
5+
ARG NanoServerRepo=mcr.microsoft.com/windows/nanoserver
6+
7+
# Use server core as an installer container to extract PowerShell,
8+
# As this is a multi-stage build, this stage will eventually be thrown away
9+
FROM ${InstallerRepo}:$InstallerVersion AS installer-env
10+
11+
# Arguments for installing PowerShell, must be defined in the container they are used
12+
ARG PS_VERSION=7.0.0-rc.1
13+
14+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip
15+
16+
# disable telemetry
17+
ENV POWERSHELL_TELEMETRY_OPTOUT="1"
18+
19+
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
20+
21+
ARG PS_PACKAGE_URL_BASE64
22+
23+
RUN Write-host "Verifying valid Version..."; `
24+
if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) { `
25+
throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION) `
26+
} `
27+
$ProgressPreference = 'SilentlyContinue'; `
28+
if($env:PS_PACKAGE_URL_BASE64){ `
29+
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;`
30+
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64)) `
31+
} else { `
32+
Write-host "using url: $env:PS_PACKAGE_URL" ;`
33+
$url = $env:PS_PACKAGE_URL `
34+
} `
35+
Write-host "downloading: $url"; `
36+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
37+
New-Item -ItemType Directory /installer > $null ; `
38+
Invoke-WebRequest -Uri $url -outfile /installer/powershell.zip -verbose; `
39+
Expand-Archive /installer/powershell.zip -DestinationPath \PowerShell
40+
41+
# Install PowerShell into NanoServer
42+
FROM ${NanoServerRepo}:20H2
43+
44+
ARG IMAGE_NAME=mcr.microsoft.com/powershell
45+
46+
# Copy PowerShell Core from the installer container
47+
ENV ProgramFiles="C:\Program Files" `
48+
# set a fixed location for the Module analysis cache
49+
PSModuleAnalysisCachePath="C:\Users\Public\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" `
50+
# Persist %PSCORE% ENV variable for user convenience
51+
PSCORE="$ProgramFiles\PowerShell\pwsh.exe" `
52+
# Set the default windows path so we can use it
53+
WindowsPATH="C:\Windows\system32;C:\Windows" `
54+
POWERSHELL_DISTRIBUTION_CHANNEL="PSDocker-NanoServer-20H2"
55+
56+
### Begin workaround ###
57+
# Note that changing user on nanoserver is not recommended
58+
# See, https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images#base-image-differences
59+
# But we are working around a bug introduced in the nanoserver image introduced in 1809
60+
# Without this, PowerShell Direct will fail
61+
# this command sholud be like this: https://github.com/PowerShell/PowerShell-Docker/blob/f81009c42c96af46aef81eb1515efae0ef29ad5f/release/preview/nanoserver/docker/Dockerfile#L76
62+
USER ContainerAdministrator
63+
64+
# This is basically the correct code except for the /M
65+
RUN setx PATH "%PATH%;%ProgramFiles%\PowerShell;" /M
66+
67+
USER ContainerUser
68+
### End workaround ###
69+
70+
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell"]
71+
72+
# intialize powershell module cache
73+
RUN pwsh `
74+
-NoLogo `
75+
-NoProfile `
76+
-Command " `
77+
$stopTime = (get-date).AddMinutes(15); `
78+
$ErrorActionPreference = 'Stop' ; `
79+
$ProgressPreference = 'SilentlyContinue' ; `
80+
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { `
81+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; `
82+
if((get-date) -gt $stopTime) { throw 'timout expired'} `
83+
Start-Sleep -Seconds 6 ; `
84+
}"
85+
86+
# re-enable telemetry
87+
ENV POWERSHELL_TELEMETRY_OPTOUT="0"
88+
89+
CMD ["pwsh.exe"]

release/lts/nanoserver20H2/meta.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"IsLinux": false,
3+
"PackageFormat": "PowerShell-${PS_VERSION}-win-x64.zip",
4+
"osVersion": "Nano Server, version 20H2",
5+
"shortTags": [
6+
{
7+
"Tag": "20H2"
8+
}
9+
],
10+
"tagTemplates": [
11+
"lts-nanoserver-#shorttag#",
12+
"lts-nanoserver-20H2-#fulltag#"
13+
],
14+
"Base64EncodePackageUrl": true,
15+
"TestProperties": {
16+
"size": 1
17+
},
18+
"UseAcr": true,
19+
"IsBroken": true
20+
}

release/lts/windowsservercore2004/dependabot/Dockerfile renamed to release/lts/windowsservercore20H2/dependabot/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
# Dummy docker image to trigger dependabot PRs
55

6-
FROM mcr.microsoft.com/windows/servercore:2004
6+
FROM mcr.microsoft.com/windows/servercore:20H2
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# escape=`
2+
ARG WindowsServerCoreRepo=mcr.microsoft.com/windows/servercore
3+
4+
# Use server core as an installer container to extract PowerShell,
5+
# As this is a multi-stage build, this stage will eventually be thrown away
6+
FROM ${WindowsServerCoreRepo}:20H2 AS installer-env
7+
8+
ARG PS_VERSION=7.0.0
9+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/PowerShell-${PS_VERSION}-win-x64.zip
10+
11+
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
12+
13+
ARG PS_PACKAGE_URL_BASE64
14+
15+
RUN Write-host "Verifying valid Version..."; `
16+
if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) { `
17+
throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION) `
18+
} `
19+
$ProgressPreference = 'SilentlyContinue'; `
20+
if($env:PS_PACKAGE_URL_BASE64){ `
21+
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;`
22+
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64)) `
23+
} else { `
24+
Write-host "using url: $env:PS_PACKAGE_URL" ;`
25+
$url = $env:PS_PACKAGE_URL `
26+
} `
27+
Write-host "downloading: $url"; `
28+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
29+
Invoke-WebRequest -Uri $url -outfile /powershell.zip -verbose; `
30+
Expand-Archive powershell.zip -DestinationPath \PowerShell
31+
32+
# Install PowerShell into WindowsServerCore
33+
FROM ${WindowsServerCoreRepo}:20H2
34+
35+
# Copy PowerShell Core from the installer container
36+
ENV ProgramFiles="C:\Program Files" `
37+
# set a fixed location for the Module analysis cache
38+
PSModuleAnalysisCachePath="C:\Users\Public\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" `
39+
# Persist %PSCORE% ENV variable for user convenience
40+
PSCORE="$ProgramFiles\PowerShell\pwsh.exe" `
41+
POWERSHELL_DISTRIBUTION_CHANNEL="PSDocker-WindowsServerCore-20H2" `
42+
POWERSHELL_TELEMETRY_OPTOUT="1"
43+
44+
# Copy PowerShell Core from the installer container
45+
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell\\latest"]
46+
47+
# Set the path
48+
RUN setx /M PATH "%ProgramFiles%\PowerShell\latest;%PATH%;"
49+
50+
# intialize powershell module cache
51+
RUN pwsh `
52+
-NoLogo `
53+
-NoProfile `
54+
-Command " `
55+
$stopTime = (get-date).AddMinutes(15); `
56+
$ErrorActionPreference = 'Stop' ; `
57+
$ProgressPreference = 'SilentlyContinue' ; `
58+
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { `
59+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; `
60+
if((get-date) -gt $stopTime) { throw 'timout expired'} `
61+
Start-Sleep -Seconds 6 ; `
62+
}"
63+
64+
# re-enable telemetry
65+
ENV POWERSHELL_TELEMETRY_OPTOUT="0"
66+
67+
CMD ["pwsh.exe"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"IsLinux": false,
3+
"PackageFormat": "PowerShell-${PS_VERSION}-win-x64.zip",
4+
"osVersion": "Windows Server Core, version 20H2",
5+
"shortTags": [
6+
{
7+
"Tag": "20H2"
8+
}
9+
],
10+
"Base64EncodePackageUrl": true,
11+
"tagTemplates": [
12+
"lts-windowsservercore-#shorttag#",
13+
"lts-windowsservercore-20H2-#fulltag#"
14+
],
15+
"TestProperties": {
16+
"size": 1
17+
},
18+
"UseAcr": true,
19+
"IsBroken": true
20+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# escape=`
2+
# Args used by from statements must be defined here:
3+
ARG InstallerVersion=nanoserver
4+
ARG InstallerRepo=mcr.microsoft.com/powershell
5+
ARG NanoServerRepo=mcr.microsoft.com/windows/nanoserver
6+
7+
# Use server core as an installer container to extract PowerShell,
8+
# As this is a multi-stage build, this stage will eventually be thrown away
9+
FROM ${InstallerRepo}:$InstallerVersion AS installer-env
10+
11+
# Arguments for installing PowerShell, must be defined in the container they are used
12+
ARG PS_VERSION=7.0.0-rc.1
13+
14+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip
15+
16+
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
17+
18+
# disable telemetry
19+
ENV POWERSHELL_TELEMETRY_OPTOUT="1"
20+
21+
ARG PS_PACKAGE_URL_BASE64
22+
23+
RUN Write-host "Verifying valid Version..."; `
24+
if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) { `
25+
throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION) `
26+
} `
27+
$ProgressPreference = 'SilentlyContinue'; `
28+
if($env:PS_PACKAGE_URL_BASE64){ `
29+
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;`
30+
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64)) `
31+
} else { `
32+
Write-host "using url: $env:PS_PACKAGE_URL" ;`
33+
$url = $env:PS_PACKAGE_URL `
34+
} `
35+
Write-host "downloading: $url"; `
36+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
37+
New-Item -ItemType Directory /installer > $null ; `
38+
Invoke-WebRequest -Uri $url -outfile /installer/powershell.zip -verbose; `
39+
Expand-Archive /installer/powershell.zip -DestinationPath \PowerShell
40+
41+
# Install PowerShell into NanoServer
42+
FROM ${NanoServerRepo}:20H2
43+
44+
# Copy PowerShell Core from the installer container
45+
ENV ProgramFiles="C:\Program Files" `
46+
# set a fixed location for the Module analysis cache
47+
PSModuleAnalysisCachePath="C:\Users\Public\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" `
48+
# Persist %PSCORE% ENV variable for user convenience
49+
PSCORE="$ProgramFiles\PowerShell\pwsh.exe" `
50+
# Set the default windows path so we can use it
51+
WindowsPATH="C:\Windows\system32;C:\Windows" `
52+
POWERSHELL_DISTRIBUTION_CHANNEL="PSDocker-NanoServer-20H2"
53+
54+
### Begin workaround ###
55+
# Note that changing user on nanoserver is not recommended
56+
# See, https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/container-base-images#base-image-differences
57+
# But we are working around a bug introduced in the nanoserver image introduced in 1809
58+
# Without this, PowerShell Direct will fail
59+
# this command sholud be like this: https://github.com/PowerShell/PowerShell-Docker/blob/f81009c42c96af46aef81eb1515efae0ef29ad5f/release/preview/nanoserver/docker/Dockerfile#L76
60+
USER ContainerAdministrator
61+
62+
# This is basically the correct code except for the /M
63+
RUN setx PATH "%PATH%;%ProgramFiles%\PowerShell;" /M
64+
65+
USER ContainerUser
66+
### End workaround ###
67+
68+
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell"]
69+
70+
# intialize powershell module cache
71+
RUN pwsh `
72+
-NoLogo `
73+
-NoProfile `
74+
-Command " `
75+
$stopTime = (get-date).AddMinutes(15); `
76+
$ErrorActionPreference = 'Stop' ; `
77+
$ProgressPreference = 'SilentlyContinue' ; `
78+
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { `
79+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; `
80+
if((get-date) -gt $stopTime) { throw 'timout expired'} `
81+
Start-Sleep -Seconds 6 ; `
82+
}"
83+
84+
# re-enable telemetry
85+
ENV POWERSHELL_TELEMETRY_OPTOUT="0"
86+
87+
CMD ["pwsh.exe"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"IsLinux": false,
3+
"PackageFormat": "PowerShell-${PS_VERSION}-win-x64.zip",
4+
"osVersion": "Nano Server, version 20H2",
5+
"shortTags": [
6+
{
7+
"Tag": "20H2"
8+
}
9+
],
10+
"tagTemplates": [
11+
"#psversion#-nanoserver-#shorttag#",
12+
"#psversion#-nanoserver-20H2-#fulltag#",
13+
"preview-nanoserver-#shorttag#"
14+
],
15+
"Base64EncodePackageUrl": true,
16+
"TestProperties": {
17+
"size": 1
18+
},
19+
"UseAcr": true,
20+
"IsBroken": true
21+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# escape=`
2+
ARG WindowsServerCoreRepo=mcr.microsoft.com/windows/servercore
3+
4+
# Use server core as an installer container to extract PowerShell,
5+
# As this is a multi-stage build, this stage will eventually be thrown away
6+
FROM ${WindowsServerCoreRepo}:20H2 AS installer-env
7+
8+
ARG PS_VERSION=7.0.0-preview.1
9+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/PowerShell-${PS_VERSION}-win-x64.zip
10+
11+
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
12+
13+
ARG PS_PACKAGE_URL_BASE64
14+
15+
RUN Write-host "Verifying valid Version..."; `
16+
if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) { `
17+
throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION) `
18+
} `
19+
$ProgressPreference = 'SilentlyContinue'; `
20+
if($env:PS_PACKAGE_URL_BASE64){ `
21+
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;`
22+
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64)) `
23+
} else { `
24+
Write-host "using url: $env:PS_PACKAGE_URL" ;`
25+
$url = $env:PS_PACKAGE_URL `
26+
} `
27+
Write-host "downloading: $url"; `
28+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
29+
Invoke-WebRequest -Uri $url -outfile /powershell.zip -verbose; `
30+
Expand-Archive powershell.zip -DestinationPath \PowerShell
31+
32+
# Install PowerShell into WindowsServerCore
33+
FROM ${WindowsServerCoreRepo}:20H2
34+
35+
# Copy PowerShell Core from the installer container
36+
ENV ProgramFiles="C:\Program Files" `
37+
# set a fixed location for the Module analysis cache
38+
PSModuleAnalysisCachePath="C:\Users\Public\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" `
39+
# Persist %PSCORE% ENV variable for user convenience
40+
PSCORE="$ProgramFiles\PowerShell\pwsh.exe" `
41+
POWERSHELL_DISTRIBUTION_CHANNEL="PSDocker-WindowsServerCore-20H2" `
42+
POWERSHELL_TELEMETRY_OPTOUT="1"
43+
44+
# Copy PowerShell Core from the installer container
45+
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell\\latest"]
46+
47+
# Set the path
48+
RUN setx /M PATH "%ProgramFiles%\PowerShell\latest;%PATH%;"
49+
50+
# intialize powershell module cache
51+
RUN pwsh `
52+
-NoLogo `
53+
-NoProfile `
54+
-Command " `
55+
$stopTime = (get-date).AddMinutes(15); `
56+
$ErrorActionPreference = 'Stop' ; `
57+
$ProgressPreference = 'SilentlyContinue' ; `
58+
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { `
59+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; `
60+
if((get-date) -gt $stopTime) { throw 'timout expired'} `
61+
Start-Sleep -Seconds 6 ; `
62+
}"
63+
64+
# re-enable telemetry
65+
ENV POWERSHELL_TELEMETRY_OPTOUT="0"
66+
67+
CMD ["pwsh.exe"]

0 commit comments

Comments
 (0)