Last active
July 14, 2020 14:29
-
-
Save GerryWilko/1a9914c137ac70aecae2c3828a30a4c0 to your computer and use it in GitHub Desktop.
Dockerfile for .NET Framework Web with cache helper for nuget restore (Windows Containers)
This file contains hidden or 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
# escape=` | |
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-2004 as cached | |
WORKDIR /cache | |
COPY . . | |
RUN Get-ChildItem . -exclude *.csproj, packages.config -Recurse | Where-Object { !$_.PSIsContainer } | ` | |
Foreach-Object { ` | |
Remove-Item $_.FullName ; ` | |
} | |
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-2004 as build-stage | |
RUN Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile "$env:temp/dotnet-install.ps1"; powershell "$env:temp/dotnet-install.ps1" | |
WORKDIR /app | |
COPY ./*.sln ./nuget.config ./ | |
COPY --from=cached /cache/. . | |
RUN nuget restore | |
COPY . . | |
RUN msbuild Wintrix.sln /p:Configuration=Docker ` | |
/p:Platform='any cpu' ` | |
/p:DeployOnBuild=true ` | |
/p:DeployDefaultTarget=WebPublish ` | |
/p:WebPublishMethod=FileSystem ` | |
/p:PublishUrl=/out ` | |
/m:4 | |
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-2004 as production-stage | |
ARG source | |
WORKDIR /inetpub/wwwroot | |
COPY --from=build-stage /out/. . | |
RUN mkdir App_Data | |
RUN icacls App_Data /grant IIS_IUSRS:F /t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment