Skip to content

Commit 6222eac

Browse files
authored
Create 2022 server image (#573)
1 parent b9991c2 commit 6222eac

File tree

6 files changed

+285
-0
lines changed

6 files changed

+285
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# escape=`
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
5+
ARG dockerHost=mcr.microsoft.com
6+
ARG WindowsServerRepo=windows/server
7+
ARG tag=ltsc2022
8+
9+
# Use server core as an installer container to extract PowerShell,
10+
# As this is a multi-stage build, this stage will eventually be thrown away
11+
FROM mcr.microsoft.com/${WindowsServerRepo}:${tag} AS installer-env
12+
13+
ARG PS_VERSION=6.2.0
14+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/PowerShell-${PS_VERSION}-win-x64.zip
15+
16+
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
17+
18+
ARG PS_PACKAGE_URL_BASE64
19+
20+
RUN Write-host "Verifying valid Version..."; `
21+
if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) { `
22+
throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION) `
23+
} `
24+
$ProgressPreference = 'SilentlyContinue'; `
25+
if($env:PS_PACKAGE_URL_BASE64){ `
26+
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;`
27+
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64)) `
28+
} else { `
29+
Write-host "using url: $env:PS_PACKAGE_URL" ;`
30+
$url = $env:PS_PACKAGE_URL `
31+
} `
32+
Write-host "downloading: $url"; `
33+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
34+
Invoke-WebRequest -Uri $url -outfile /powershell.zip -verbose; `
35+
Expand-Archive powershell.zip -DestinationPath \PowerShell
36+
37+
# Install PowerShell into WindowsServer
38+
FROM mcr.microsoft.com/${WindowsServerRepo}:${tag}
39+
40+
# Copy PowerShell Core from the installer container
41+
ENV ProgramFiles="C:\Program Files" `
42+
# set a fixed location for the Module analysis cache
43+
PSModuleAnalysisCachePath="C:\Users\Public\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" `
44+
# Persist %PSCORE% ENV variable for user convenience
45+
PSCORE="$ProgramFiles\PowerShell\pwsh.exe" `
46+
POWERSHELL_DISTRIBUTION_CHANNEL="PSDocker-WindowsServer-ltsc2022" `
47+
POWERSHELL_TELEMETRY_OPTOUT="1"
48+
49+
# Copy PowerShell Core from the installer container
50+
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell\\latest"]
51+
52+
# Set the path
53+
RUN setx /M PATH "%ProgramFiles%\PowerShell\latest;%PATH%;"
54+
55+
# intialize powershell module cache
56+
RUN pwsh `
57+
-NoLogo `
58+
-NoProfile `
59+
-Command " `
60+
$stopTime = (get-date).AddMinutes(15); `
61+
$ErrorActionPreference = 'Stop' ; `
62+
$ProgressPreference = 'SilentlyContinue' ; `
63+
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { `
64+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; `
65+
if((get-date) -gt $stopTime) { throw 'timout expired'} `
66+
Start-Sleep -Seconds 6 ; `
67+
}"
68+
69+
# re-enable telemetry
70+
ENV POWERSHELL_TELEMETRY_OPTOUT="0"
71+
72+
CMD ["pwsh.exe"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"IsLinux": false,
3+
"PackageFormat": "PowerShell-${PS_VERSION}-win-x64.zip",
4+
"osVersion": "Windows Server, LTSC 2022",
5+
"shortTags": [
6+
{
7+
"Tag": "ltsc2022"
8+
}
9+
],
10+
"Base64EncodePackageUrl": true,
11+
"tagTemplates": [
12+
"lts-#psversion#-windowsserver-#shorttag#",
13+
"lts-windowsserver-#shorttag#",
14+
"lts-windowsserver-#shorttag#-#fulltag#"
15+
],
16+
"manifestLists": [
17+
"lts"
18+
],
19+
"TestProperties": {
20+
"size": 1
21+
},
22+
"UseAcr": true
23+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# escape=`
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
5+
ARG dockerHost=mcr.microsoft.com
6+
ARG WindowsServerRepo=windows/server
7+
ARG tag=ltsc2022
8+
9+
# Use server core as an installer container to extract PowerShell,
10+
# As this is a multi-stage build, this stage will eventually be thrown away
11+
FROM mcr.microsoft.com/${WindowsServerRepo}:${tag} AS installer-env
12+
13+
ARG PS_VERSION=6.2.0
14+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/PowerShell-${PS_VERSION}-win-x64.zip
15+
16+
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
17+
18+
ARG PS_PACKAGE_URL_BASE64
19+
20+
RUN Write-host "Verifying valid Version..."; `
21+
if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) { `
22+
throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION) `
23+
} `
24+
$ProgressPreference = 'SilentlyContinue'; `
25+
if($env:PS_PACKAGE_URL_BASE64){ `
26+
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;`
27+
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64)) `
28+
} else { `
29+
Write-host "using url: $env:PS_PACKAGE_URL" ;`
30+
$url = $env:PS_PACKAGE_URL `
31+
} `
32+
Write-host "downloading: $url"; `
33+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
34+
Invoke-WebRequest -Uri $url -outfile /powershell.zip -verbose; `
35+
Expand-Archive powershell.zip -DestinationPath \PowerShell
36+
37+
# Install PowerShell into WindowsServer
38+
FROM mcr.microsoft.com/${WindowsServerRepo}:${tag}
39+
40+
# Copy PowerShell Core from the installer container
41+
ENV ProgramFiles="C:\Program Files" `
42+
# set a fixed location for the Module analysis cache
43+
PSModuleAnalysisCachePath="C:\Users\Public\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" `
44+
# Persist %PSCORE% ENV variable for user convenience
45+
PSCORE="$ProgramFiles\PowerShell\pwsh.exe" `
46+
POWERSHELL_DISTRIBUTION_CHANNEL="PSDocker-WindowsServer-ltsc2022" `
47+
POWERSHELL_TELEMETRY_OPTOUT="1"
48+
49+
# Copy PowerShell Core from the installer container
50+
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell\\latest"]
51+
52+
# Set the path
53+
RUN setx /M PATH "%ProgramFiles%\PowerShell\latest;%PATH%;"
54+
55+
# intialize powershell module cache
56+
RUN pwsh `
57+
-NoLogo `
58+
-NoProfile `
59+
-Command " `
60+
$stopTime = (get-date).AddMinutes(15); `
61+
$ErrorActionPreference = 'Stop' ; `
62+
$ProgressPreference = 'SilentlyContinue' ; `
63+
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { `
64+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; `
65+
if((get-date) -gt $stopTime) { throw 'timout expired'} `
66+
Start-Sleep -Seconds 6 ; `
67+
}"
68+
69+
# re-enable telemetry
70+
ENV POWERSHELL_TELEMETRY_OPTOUT="0"
71+
72+
CMD ["pwsh.exe"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"IsLinux": false,
3+
"PackageFormat": "PowerShell-${PS_VERSION}-win-x64.zip",
4+
"osVersion": "Windows Server, LTSC 2022",
5+
"shortTags": [
6+
{
7+
"Tag": "ltsc2022"
8+
}
9+
],
10+
"Base64EncodePackageUrl": true,
11+
"tagTemplates": [
12+
"#psversion#-windowsserver-#shorttag#",
13+
"#psversion#-windowsserver-#shorttag#-#fulltag#",
14+
"preview-windowsserver-#shorttag#"
15+
],
16+
"manifestLists": [
17+
"preview-windowsserver"
18+
],
19+
"TestProperties": {
20+
"size": 1
21+
},
22+
"UseAcr": true
23+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# escape=`
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
5+
ARG dockerHost=mcr.microsoft.com
6+
ARG WindowsServerRepo=windows/server
7+
ARG tag=ltsc2022
8+
9+
# Use server core as an installer container to extract PowerShell,
10+
# As this is a multi-stage build, this stage will eventually be thrown away
11+
FROM mcr.microsoft.com/${WindowsServerRepo}:${tag} AS installer-env
12+
13+
ARG PS_VERSION=6.2.0
14+
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/PowerShell-${PS_VERSION}-win-x64.zip
15+
16+
SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"]
17+
18+
ARG PS_PACKAGE_URL_BASE64
19+
20+
RUN Write-host "Verifying valid Version..."; `
21+
if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$' )) { `
22+
throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+(\.\d+)?)?$"' -f $env:PS_VERSION) `
23+
} `
24+
$ProgressPreference = 'SilentlyContinue'; `
25+
if($env:PS_PACKAGE_URL_BASE64){ `
26+
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;`
27+
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64)) `
28+
} else { `
29+
Write-host "using url: $env:PS_PACKAGE_URL" ;`
30+
$url = $env:PS_PACKAGE_URL `
31+
} `
32+
Write-host "downloading: $url"; `
33+
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12; `
34+
Invoke-WebRequest -Uri $url -outfile /powershell.zip -verbose; `
35+
Expand-Archive powershell.zip -DestinationPath \PowerShell
36+
37+
# Install PowerShell into WindowsServer
38+
FROM mcr.microsoft.com/${WindowsServerRepo}:${tag}
39+
40+
# Copy PowerShell Core from the installer container
41+
ENV ProgramFiles="C:\Program Files" `
42+
# set a fixed location for the Module analysis cache
43+
PSModuleAnalysisCachePath="C:\Users\Public\AppData\Local\Microsoft\Windows\PowerShell\docker\ModuleAnalysisCache" `
44+
# Persist %PSCORE% ENV variable for user convenience
45+
PSCORE="$ProgramFiles\PowerShell\pwsh.exe" `
46+
POWERSHELL_DISTRIBUTION_CHANNEL="PSDocker-WindowsServer-ltsc2022" `
47+
POWERSHELL_TELEMETRY_OPTOUT="1"
48+
49+
# Copy PowerShell Core from the installer container
50+
COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell\\latest"]
51+
52+
# Set the path
53+
RUN setx /M PATH "%ProgramFiles%\PowerShell\latest;%PATH%;"
54+
55+
# intialize powershell module cache
56+
RUN pwsh `
57+
-NoLogo `
58+
-NoProfile `
59+
-Command " `
60+
$stopTime = (get-date).AddMinutes(15); `
61+
$ErrorActionPreference = 'Stop' ; `
62+
$ProgressPreference = 'SilentlyContinue' ; `
63+
while(!(Test-Path -Path $env:PSModuleAnalysisCachePath)) { `
64+
Write-Host "'Waiting for $env:PSModuleAnalysisCachePath'" ; `
65+
if((get-date) -gt $stopTime) { throw 'timout expired'} `
66+
Start-Sleep -Seconds 6 ; `
67+
}"
68+
69+
# re-enable telemetry
70+
ENV POWERSHELL_TELEMETRY_OPTOUT="0"
71+
72+
CMD ["pwsh.exe"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"IsLinux": false,
3+
"PackageFormat": "PowerShell-${PS_VERSION}-win-x64.zip",
4+
"osVersion": "Windows Server, LTSC 2022",
5+
"shortTags": [
6+
{
7+
"Tag": "ltsc2022"
8+
}
9+
],
10+
"Base64EncodePackageUrl": true,
11+
"tagTemplates": [
12+
"#psversion#-windowsserver-#shorttag#",
13+
"#psversion#-windowsserver-#shorttag#-#fulltag#",
14+
"windowsserver-#shorttag#"
15+
],
16+
"manifestLists": [
17+
"windowsserver"
18+
],
19+
"TestProperties": {
20+
"size": 1
21+
},
22+
"UseAcr": true
23+
}

0 commit comments

Comments
 (0)