Created
January 6, 2020 11:59
-
-
Save NBprojekt/2055cba6897d409076e09cff9c7f1635 to your computer and use it in GitHub Desktop.
Dockerfile to host dotnet core apps like blazor using IIS (dotnet core 3.0)
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
# Use iis as base image and install dotnet 3.0.1 hosting pack | |
FROM microsoft/iis as base | |
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"] | |
ADD https://download.visualstudio.microsoft.com/download/pr/32b71802-0b4d-4064-a7e6-083b5155d3b1/080cf60a5c06be4ed27e2eac6c693f2f/dotnet-hosting-3.0.1-win.exe "C:/setup/dotnet-hosting-3.0.1-win.exe" | |
RUN start-process -Filepath "C:/setup/dotnet-hosting-3.0.1-win.exe" -ArgumentList @('/install', '/quiet', '/norestart') -Wait | |
RUN Remove-Item -Force "C:/setup/dotnet-hosting-3.0.1-win.exe" | |
############################################################################################################## | |
# Use dotnet core sdk as build image | |
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build | |
WORKDIR /app | |
# Copy csproj and restore as distinct layers | |
COPY *.sln . | |
COPY ./{PROJECT_NAME}/*.csproj ./{PROJECT_NAME}/ | |
RUN dotnet restore | |
# Copy everything else and build app | |
COPY ./{PROJECT_NAME}/. ./{PROJECT_NAME}/ | |
RUN dotnet publish -c Release -o out | |
############################################################################################################## | |
# Create final image | |
FROM base AS final | |
WORKDIR /inetpub/wwwroot/{PROJECT_NAME} | |
RUN Import-Module WebAdministration | |
RUN Remove-Website -Name 'Default Web Site' | |
# Create pool | |
RUN New-WebAppPool -Name '{PROJECT_NAME}-pool'; \ | |
Set-ItemProperty IIS:\AppPools\{PROJECT_NAME}-pool -Name managedRuntimeVersion -Value ''; \ | |
Set-ItemProperty IIS:\AppPools\{PROJECT_NAME}-pool -Name enable32BitAppOnWin64 -Value 0; \ | |
Set-ItemProperty IIS:\AppPools\{PROJECT_NAME}-pool -Name processModel.identityType -Value Service | |
# Create new Website | |
RUN New-Website -Name '{PROJECT_NAME}' \ | |
-Port 80 -PhysicalPath 'C:\inetpub\wwwroot\{PROJECT_NAME}' \ | |
-ApplicationPool '{PROJECT_NAME}-pool' -force | |
# Copy output from build img | |
COPY --from=build /app/out . | |
EXPOSE 80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment