Skip to content

Commit cd19c51

Browse files
authored
Use installer stage for Windows Server Core Dockerfiles (#6249)
1 parent 0b958c6 commit cd19c51

File tree

62 files changed

+725
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+725
-424
lines changed

eng/dockerfile-templates/aspnet/Dockerfile.windows

+2-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
set baseUrl to VARIABLES[cat("dotnet|", dotnetVersion, "|base-url|", VARIABLES["branch"])] ^
66
set isInternal to find(baseUrl, "artifacts.visualstudio.com") >= 0 ^
7-
set isSingleStage to (find(OS_VERSION, "windowsservercore") >= 0 && !isInternal) ^
87

98
set installerStageFromImage to cat("mcr.microsoft.com/windows/servercore:", OS_VERSION_NUMBER, "-amd64") ^
109

@@ -14,20 +13,8 @@
1413
}}# escape=`
1514

1615
ARG REPO=mcr.microsoft.com/dotnet/runtime
17-
{{if isSingleStage:{{
1816

19-
_ SINGLE STAGE
20-
21-
}}FROM {{runtimeStageFromImage}}
22-
23-
{{InsertTemplate("Dockerfile.envs", ["is-internal": isInternal])}}
24-
25-
{{InsertTemplate("Dockerfile.windows.install-aspnet")}}^else:
26-
{{
27-
28-
_ MULTI STAGE
29-
30-
}}# Installer image
17+
# Installer image
3118
FROM {{installerStageFromImage}} AS installer
3219
{{if isInternal:
3320
ARG ACCESSTOKEN
@@ -44,4 +31,4 @@ FROM {{runtimeStageFromImage}}
4431

4532
{{InsertTemplate("Dockerfile.envs", ["is-internal": isInternal])}}
4633

47-
COPY --from=installer ["/dotnet/shared/Microsoft.AspNetCore.App", "/Program Files/dotnet/shared/Microsoft.AspNetCore.App"]}}
34+
COPY --from=installer ["/dotnet/shared/Microsoft.AspNetCore.App", "/Program Files/dotnet/shared/Microsoft.AspNetCore.App"]

eng/dockerfile-templates/aspnet/Dockerfile.windows.install-aspnet

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
set dotnetVersion to join(slice(split(PRODUCT_VERSION, "."), 0, 2), ".") ^
88
set isServerCore to find(OS_VERSION, "windowsservercore") >= 0 ^
99
set isNanoServer to find(OS_VERSION, "nanoserver") >= 0 ^
10-
set useProgramFilesDir to (isServerCore && !ARGS["is-internal"]) ^
11-
set dotnetDir to when(useProgramFilesDir, "$Env:ProgramFiles\dotnet", "dotnet") ^
10+
set dotnetDir to "dotnet" ^
1211
set aspnetCoreZipFile to "aspnetcore.zip" ^
1312
set aspnetVersion to when(ARGS["use-local-version-var"], "$aspnetcore_version", "$Env:ASPNET_VERSION") ^
1413
set isStableBranding to (find(VARIABLES[cat("sdk|", dotnetVersion, "|build-version")], "-servicing") >= 0 ||
@@ -33,8 +32,8 @@ RUN powershell -Command `
3332
"sha-var-name": "aspnetcore_sha512"
3433
], " ")}}; `
3534
`
36-
{{if !useProgramFilesDir:mkdir {{dotnetDir}}/shared/Microsoft.AspNetCore.App; `
37-
}}{{InsertTemplate("../Dockerfile.windows.extract-zip",
35+
mkdir {{dotnetDir}}/shared/Microsoft.AspNetCore.App; `
36+
{{InsertTemplate("../Dockerfile.windows.extract-zip",
3837
[
3938
"file": aspnetCoreZipFile,
4039
"dest-dir": dotnetDir,

eng/dockerfile-templates/runtime/Dockerfile.windows

+2-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
set baseUrl to VARIABLES[cat("dotnet|", dotnetVersion, "|base-url|", VARIABLES["branch"])] ^
77
set isInternal to find(baseUrl, "artifacts.visualstudio.com") >= 0 ^
8-
set isSingleStage to find(OS_VERSION, "windowsservercore") >= 0 && !isInternal ^
98

109
set installerStageRepo to cat("mcr.microsoft.com/windows/", "servercore") ^
1110
set runtimeStageRepo to cat("mcr.microsoft.com/windows/", when(isServerCore, "servercore", "nanoserver")) ^
@@ -17,24 +16,7 @@
1716

1817
}}# escape=`
1918

20-
{{if isSingleStage:{{
21-
22-
_ SINGLE STAGE
23-
24-
}}FROM {{runtimeStageFromImage}}
25-
26-
{{InsertTemplate("../Dockerfile.common-dotnet-envs")}} `
27-
{{InsertTemplate("Dockerfile.envs", ["is-internal": isInternal], " ")}}
28-
29-
# Install .NET Runtime
30-
{{InsertTemplate("Dockerfile.windows.install-runtime")}}
31-
32-
{{InsertTemplate("../Dockerfile.windows.set-path", [ "path": "C:\Program Files\dotnet"])}}^
33-
else:{{
34-
35-
_ MULTI STAGE
36-
37-
}}# Installer image
19+
# Installer image
3820
FROM {{installerStageFromImage}} AS installer
3921
{{if isInternal:
4022
ARG ACCESSTOKEN
@@ -55,4 +37,4 @@ FROM {{runtimeStageFromImage}}
5537

5638
{{InsertTemplate("../Dockerfile.windows.set-path", [ "path": "C:\Program Files\dotnet"])}}
5739

58-
COPY --from=installer ["/dotnet", "/Program Files/dotnet"]}}
40+
COPY --from=installer ["/dotnet", "/Program Files/dotnet"]

eng/dockerfile-templates/runtime/Dockerfile.windows.install-runtime

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
set dotnetVersion to join(slice(split(PRODUCT_VERSION, "."), 0, 2), ".") ^
88
set isServerCore to find(OS_VERSION, "windowsservercore") >= 0 ^
9-
set dotnetDir to when(isServerCore && !ARGS["is-internal"], "$Env:ProgramFiles\dotnet", "dotnet") ^
9+
set dotnetDir to "dotnet" ^
1010
set dotnetZipFile to "dotnet.zip" ^
1111
set runtimeVersionDir to when(ARGS["use-local-version-var"],
1212
"$dotnet_version",

eng/dockerfile-templates/sdk/Dockerfile.windows

+3-18
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,8 @@
1818
}}# escape=`
1919

2020
ARG REPO=mcr.microsoft.com/dotnet/aspnet
21-
{{if isSingleStage:{{
2221

23-
_ SINGLE STAGE
24-
25-
}}FROM {{aspnetBaseTag}}
26-
27-
{{InsertTemplate("Dockerfile.envs", ["is-internal": isInternal, "include-powershell-vars": "true"])}}
28-
29-
{{InsertTemplate("Dockerfile.windows.install-components")}}
30-
31-
{{InsertTemplate("../Dockerfile.windows.set-path", [ "path": paths ])}}
32-
33-
{{InsertTemplate("Dockerfile.windows.first-run")}}^else:
34-
{{
35-
36-
_ MULTI STAGE
37-
38-
}}# Installer image
22+
# Installer image
3923
FROM {{installerStageFromImage}} AS installer
4024
{{if isInternal:
4125
ARG ACCESSTOKEN
@@ -46,6 +30,7 @@ ARG ACCESSTOKEN
4630
"dotnet-is-internal": isInternal,
4731
])}}
4832

33+
4934
# SDK image
5035
FROM {{aspnetBaseTag}}
5136

@@ -57,4 +42,4 @@ COPY --from=installer ["/dotnet", "/Program Files/dotnet"]
5742
COPY --from=installer ["/powershell", "/Program Files/powershell"]
5843
COPY --from=installer ["/MinGit", "/Program Files/MinGit"]
5944

60-
{{InsertTemplate("Dockerfile.windows.first-run")}}}}
45+
{{InsertTemplate("Dockerfile.windows.first-run")}}

eng/dockerfile-templates/sdk/Dockerfile.windows.install-components

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
]
2727
]
2828
] ^
29-
set isSingleStage to (isServerCore && !ARGS["dotnet-is-internal"]) ^
3029
set getFormattedPath(path) to:{{
3130
return cat("'", path, "'")
3231
}} ^
33-
set mingitDir to when(isSingleStage, "$Env:ProgramFiles\MinGit", "MinGit")
32+
set mingitDir to "MinGit"
3433
}}# Download MinGit
3534
RUN powershell -Command " `
3635
$ErrorActionPreference = 'Stop'; `
@@ -60,7 +59,7 @@ RUN `^else:RUN powershell -Command " `}}
6059
{{InsertTemplate("Dockerfile.windows.install-sdk",
6160
[
6261
"use-local-version-var": ARGS["use-local-version-var"],
63-
"sdk-extract-groups": when(isSingleStage, sdkExtractGroups, []),
62+
"sdk-extract-groups": [],
6463
"is-internal": ARGS["dotnet-is-internal"]
6564
], " ")}} `
6665
`

eng/dockerfile-templates/sdk/Dockerfile.windows.install-powershell

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
dotnet-is-internal (optional): Whether the Dockerfile is targeting an internal build of the .NET product. ^
44

55
set dotnetVersion to join(slice(split(PRODUCT_VERSION, "."), 0, 2), ".") ^
6-
set isNanoServer to find(OS_VERSION, "nanoserver") >= 0 ^
7-
set rootDir to when(isNanoServer || ARGS["dotnet-is-internal"], "\", "$Env:ProgramFiles\") ^
6+
set rootDir to "\" ^
87
set nupkgFile to "PowerShell.Windows.x64.$powershell_version.nupkg" ^
98
set url to cat("https://powershellinfraartifacts-gkhedzdeaghdezhr.z01.azurefd.net/tool/$powershell_version/", nupkgFile) ^
109
set powershellVersion to VARIABLES[cat("powershell|", dotnetVersion, "|build-version")]

eng/dockerfile-templates/sdk/Dockerfile.windows.install-sdk

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
set dotnetVersion to join(slice(split(PRODUCT_VERSION, "."), 0, 2), ".") ^
99
set isServerCore to find(OS_VERSION, "windowsservercore") >= 0 ^
1010
set dotnetZipFile to "dotnet.zip" ^
11-
set useProgramFilesDir to (isServerCore && !ARGS["is-internal"]) ^
12-
set dotnetDir to when(useProgramFilesDir, "$Env:ProgramFiles\dotnet", "dotnet") ^
11+
set dotnetDir to "dotnet" ^
1312
set sdkVersionDir to when(ARGS["use-local-version-var"],
1413
"$sdk_version",
1514
when(ARGS["is-internal"],
@@ -48,8 +47,8 @@
4847
"url": url,
4948
"sha": VARIABLES[cat("sdk|", dotnetVersion, "|win|x64|sha")],
5049
"sha-var-name": "dotnet_sha512"
51-
])}}; `{{if !useProgramFilesDir:
52-
mkdir {{dotnetDir}}; `}}
50+
])}}; `
51+
mkdir {{dotnetDir}}; `
5352
{{InsertTemplate("../Dockerfile.windows.extract-zip",
5453
[
5554
"file": dotnetZipFile,
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
# escape=`
22

33
ARG REPO=mcr.microsoft.com/dotnet/runtime
4-
FROM $REPO:10.0.0-preview.1-windowsservercore-ltsc2019
54

6-
# ASP.NET Core version
7-
ENV ASPNET_VERSION=10.0.0-preview.1.25107.4
5+
# Installer image
6+
FROM mcr.microsoft.com/windows/servercore:ltsc2019-amd64 AS installer
87

98
# Install ASP.NET Core Runtime
109
RUN powershell -Command `
1110
$ErrorActionPreference = 'Stop'; `
1211
$ProgressPreference = 'SilentlyContinue'; `
1312
`
14-
Invoke-WebRequest -OutFile aspnetcore.zip https://ci.dot.net/public/aspnetcore/Runtime/$Env:ASPNET_VERSION/aspnetcore-runtime-$Env:ASPNET_VERSION-win-x64.zip; `
13+
$aspnetcore_version = '10.0.0-preview.1.25107.4'; `
14+
Invoke-WebRequest -OutFile aspnetcore.zip https://ci.dot.net/public/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-win-x64.zip; `
1515
$aspnetcore_sha512 = '223845f68745b98fee96eb7aa02b2a748a8b43755b40670c4f8d3107b39c5e0faf9cf2eb5a2f58cee5f954b39186c08dffce10246e3943f82d413dccad766a06'; `
1616
if ((Get-FileHash aspnetcore.zip -Algorithm sha512).Hash -ne $aspnetcore_sha512) { `
1717
Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
1818
exit 1; `
1919
}; `
2020
`
21-
tar -oxzf aspnetcore.zip -C $Env:ProgramFiles\dotnet ./shared/Microsoft.AspNetCore.App; `
21+
mkdir dotnet/shared/Microsoft.AspNetCore.App; `
22+
tar -oxzf aspnetcore.zip -C dotnet ./shared/Microsoft.AspNetCore.App; `
2223
Remove-Item -Force aspnetcore.zip
24+
25+
26+
# ASP.NET Core image
27+
FROM $REPO:10.0.0-preview.1-windowsservercore-ltsc2019
28+
29+
# ASP.NET Core version
30+
ENV ASPNET_VERSION=10.0.0-preview.1.25107.4
31+
32+
COPY --from=installer ["/dotnet/shared/Microsoft.AspNetCore.App", "/Program Files/dotnet/shared/Microsoft.AspNetCore.App"]
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
# escape=`
22

33
ARG REPO=mcr.microsoft.com/dotnet/runtime
4-
FROM $REPO:10.0.0-preview.1-windowsservercore-ltsc2022
54

6-
# ASP.NET Core version
7-
ENV ASPNET_VERSION=10.0.0-preview.1.25107.4
5+
# Installer image
6+
FROM mcr.microsoft.com/windows/servercore:ltsc2022-amd64 AS installer
87

98
# Install ASP.NET Core Runtime
109
RUN powershell -Command `
1110
$ErrorActionPreference = 'Stop'; `
1211
$ProgressPreference = 'SilentlyContinue'; `
1312
`
14-
Invoke-WebRequest -OutFile aspnetcore.zip https://ci.dot.net/public/aspnetcore/Runtime/$Env:ASPNET_VERSION/aspnetcore-runtime-$Env:ASPNET_VERSION-win-x64.zip; `
13+
$aspnetcore_version = '10.0.0-preview.1.25107.4'; `
14+
Invoke-WebRequest -OutFile aspnetcore.zip https://ci.dot.net/public/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-win-x64.zip; `
1515
$aspnetcore_sha512 = '223845f68745b98fee96eb7aa02b2a748a8b43755b40670c4f8d3107b39c5e0faf9cf2eb5a2f58cee5f954b39186c08dffce10246e3943f82d413dccad766a06'; `
1616
if ((Get-FileHash aspnetcore.zip -Algorithm sha512).Hash -ne $aspnetcore_sha512) { `
1717
Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
1818
exit 1; `
1919
}; `
2020
`
21-
tar -oxzf aspnetcore.zip -C $Env:ProgramFiles\dotnet ./shared/Microsoft.AspNetCore.App; `
21+
mkdir dotnet/shared/Microsoft.AspNetCore.App; `
22+
tar -oxzf aspnetcore.zip -C dotnet ./shared/Microsoft.AspNetCore.App; `
2223
Remove-Item -Force aspnetcore.zip
24+
25+
26+
# ASP.NET Core image
27+
FROM $REPO:10.0.0-preview.1-windowsservercore-ltsc2022
28+
29+
# ASP.NET Core version
30+
ENV ASPNET_VERSION=10.0.0-preview.1.25107.4
31+
32+
COPY --from=installer ["/dotnet/shared/Microsoft.AspNetCore.App", "/Program Files/dotnet/shared/Microsoft.AspNetCore.App"]
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
# escape=`
22

33
ARG REPO=mcr.microsoft.com/dotnet/runtime
4-
FROM $REPO:10.0.0-preview.1-windowsservercore-ltsc2025
54

6-
# ASP.NET Core version
7-
ENV ASPNET_VERSION=10.0.0-preview.1.25107.4
5+
# Installer image
6+
FROM mcr.microsoft.com/windows/servercore:ltsc2025-amd64 AS installer
87

98
# Install ASP.NET Core Runtime
109
RUN powershell -Command `
1110
$ErrorActionPreference = 'Stop'; `
1211
$ProgressPreference = 'SilentlyContinue'; `
1312
`
14-
Invoke-WebRequest -OutFile aspnetcore.zip https://ci.dot.net/public/aspnetcore/Runtime/$Env:ASPNET_VERSION/aspnetcore-runtime-$Env:ASPNET_VERSION-win-x64.zip; `
13+
$aspnetcore_version = '10.0.0-preview.1.25107.4'; `
14+
Invoke-WebRequest -OutFile aspnetcore.zip https://ci.dot.net/public/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-win-x64.zip; `
1515
$aspnetcore_sha512 = '223845f68745b98fee96eb7aa02b2a748a8b43755b40670c4f8d3107b39c5e0faf9cf2eb5a2f58cee5f954b39186c08dffce10246e3943f82d413dccad766a06'; `
1616
if ((Get-FileHash aspnetcore.zip -Algorithm sha512).Hash -ne $aspnetcore_sha512) { `
1717
Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
1818
exit 1; `
1919
}; `
2020
`
21-
tar -oxzf aspnetcore.zip -C $Env:ProgramFiles\dotnet ./shared/Microsoft.AspNetCore.App; `
21+
mkdir dotnet/shared/Microsoft.AspNetCore.App; `
22+
tar -oxzf aspnetcore.zip -C dotnet ./shared/Microsoft.AspNetCore.App; `
2223
Remove-Item -Force aspnetcore.zip
24+
25+
26+
# ASP.NET Core image
27+
FROM $REPO:10.0.0-preview.1-windowsservercore-ltsc2025
28+
29+
# ASP.NET Core version
30+
ENV ASPNET_VERSION=10.0.0-preview.1.25107.4
31+
32+
COPY --from=installer ["/dotnet/shared/Microsoft.AspNetCore.App", "/Program Files/dotnet/shared/Microsoft.AspNetCore.App"]
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
# escape=`
22

33
ARG REPO=mcr.microsoft.com/dotnet/runtime
4-
FROM $REPO:8.0.13-windowsservercore-ltsc2019
54

6-
# ASP.NET Core version
7-
ENV ASPNET_VERSION=8.0.13
5+
# Installer image
6+
FROM mcr.microsoft.com/windows/servercore:ltsc2019-amd64 AS installer
87

98
# Install ASP.NET Core Runtime
109
RUN powershell -Command `
1110
$ErrorActionPreference = 'Stop'; `
1211
$ProgressPreference = 'SilentlyContinue'; `
1312
`
14-
Invoke-WebRequest -OutFile aspnetcore.zip https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/$Env:ASPNET_VERSION/aspnetcore-runtime-$Env:ASPNET_VERSION-win-x64.zip; `
13+
$aspnetcore_version = '8.0.13'; `
14+
Invoke-WebRequest -OutFile aspnetcore.zip https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-win-x64.zip; `
1515
$aspnetcore_sha512 = '2cf4a7dc531cdae0d244bbd745a051c431304db230630789e26273781c32e540ba92709e51ddfd17fccdc9879e1b209a3e08783475d9c4c4446dcc74709be5d8'; `
1616
if ((Get-FileHash aspnetcore.zip -Algorithm sha512).Hash -ne $aspnetcore_sha512) { `
1717
Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
1818
exit 1; `
1919
}; `
2020
`
21-
tar -oxzf aspnetcore.zip -C $Env:ProgramFiles\dotnet ./shared/Microsoft.AspNetCore.App; `
21+
mkdir dotnet/shared/Microsoft.AspNetCore.App; `
22+
tar -oxzf aspnetcore.zip -C dotnet ./shared/Microsoft.AspNetCore.App; `
2223
Remove-Item -Force aspnetcore.zip
24+
25+
26+
# ASP.NET Core image
27+
FROM $REPO:8.0.13-windowsservercore-ltsc2019
28+
29+
# ASP.NET Core version
30+
ENV ASPNET_VERSION=8.0.13
31+
32+
COPY --from=installer ["/dotnet/shared/Microsoft.AspNetCore.App", "/Program Files/dotnet/shared/Microsoft.AspNetCore.App"]
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
# escape=`
22

33
ARG REPO=mcr.microsoft.com/dotnet/runtime
4-
FROM $REPO:8.0.13-windowsservercore-ltsc2022
54

6-
# ASP.NET Core version
7-
ENV ASPNET_VERSION=8.0.13
5+
# Installer image
6+
FROM mcr.microsoft.com/windows/servercore:ltsc2022-amd64 AS installer
87

98
# Install ASP.NET Core Runtime
109
RUN powershell -Command `
1110
$ErrorActionPreference = 'Stop'; `
1211
$ProgressPreference = 'SilentlyContinue'; `
1312
`
14-
Invoke-WebRequest -OutFile aspnetcore.zip https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/$Env:ASPNET_VERSION/aspnetcore-runtime-$Env:ASPNET_VERSION-win-x64.zip; `
13+
$aspnetcore_version = '8.0.13'; `
14+
Invoke-WebRequest -OutFile aspnetcore.zip https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/$aspnetcore_version/aspnetcore-runtime-$aspnetcore_version-win-x64.zip; `
1515
$aspnetcore_sha512 = '2cf4a7dc531cdae0d244bbd745a051c431304db230630789e26273781c32e540ba92709e51ddfd17fccdc9879e1b209a3e08783475d9c4c4446dcc74709be5d8'; `
1616
if ((Get-FileHash aspnetcore.zip -Algorithm sha512).Hash -ne $aspnetcore_sha512) { `
1717
Write-Host 'CHECKSUM VERIFICATION FAILED!'; `
1818
exit 1; `
1919
}; `
2020
`
21-
tar -oxzf aspnetcore.zip -C $Env:ProgramFiles\dotnet ./shared/Microsoft.AspNetCore.App; `
21+
mkdir dotnet/shared/Microsoft.AspNetCore.App; `
22+
tar -oxzf aspnetcore.zip -C dotnet ./shared/Microsoft.AspNetCore.App; `
2223
Remove-Item -Force aspnetcore.zip
24+
25+
26+
# ASP.NET Core image
27+
FROM $REPO:8.0.13-windowsservercore-ltsc2022
28+
29+
# ASP.NET Core version
30+
ENV ASPNET_VERSION=8.0.13
31+
32+
COPY --from=installer ["/dotnet/shared/Microsoft.AspNetCore.App", "/Program Files/dotnet/shared/Microsoft.AspNetCore.App"]

0 commit comments

Comments
 (0)