-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.windowsservercore-iis
44 lines (37 loc) · 1.6 KB
/
Dockerfile.windowsservercore-iis
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# escape=`
# Learn about building .NET container images:
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
# final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:8.0-windowsservercore-ltsc2022 AS final
RUN powershell -Command `
$ErrorActionPreference = 'Stop'; `
$ProgressPreference = 'SilentlyContinue'; `
`
# Install IIS
Add-WindowsFeature Web-Server; `
Remove-Item -Recurse C:\inetpub\wwwroot\*; `
`
# Acquire ServiceMonitor
Invoke-WebRequest -OutFile C:\ServiceMonitor.exe -Uri https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.10/ServiceMonitor.exe; `
`
# Install the ASP.NET Core Module
Invoke-WebRequest -OutFile c:\dotnet-hosting-win.exe https://aka.ms/dotnet/8.0/dotnet-hosting-win.exe; `
$process = Start-Process -Filepath C:\dotnet-hosting-win.exe -ArgumentList @('/install', '/q', '/norestart', 'OPT_NO_RUNTIME=1', 'OPT_NO_X86=1', 'OPT_NO_SHAREDFX=1') -Wait -PassThru ; `
if ($process.ExitCode -ne 0) { `
exit $process.ExitCode; `
} `
Remove-Item -Force C:\dotnet-hosting-win.exe; `
Remove-Item -Force -Recurse $Env:Temp\*
FROM mcr.microsoft.com/dotnet/sdk:8.0-windowsservercore-ltsc2022 AS build
WORKDIR /source
# copy csproj and restore as distinct layers
COPY aspnetapp/*.csproj .
RUN dotnet restore --ucr
# copy everything else and build app
COPY aspnetapp/. .
RUN dotnet publish --ucr --no-restore -o /app
FROM final
WORKDIR /inetpub/wwwroot
COPY --from=build /app .
EXPOSE 80
ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]