Skip to content

Instantly share code, notes, and snippets.

@sjwaight
Created March 29, 2021 10:31
Show Gist options
  • Save sjwaight/f95dcb48b3fb106a41169f5c3832c643 to your computer and use it in GitHub Desktop.
Save sjwaight/f95dcb48b3fb106a41169f5c3832c643 to your computer and use it in GitHub Desktop.
Full dockerfile that shows how to build and package an .NET Framework application for use with Windows Containers
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY MvcMusicStore-Completed/*.sln .
COPY MvcMusicStore-Completed/MvcMusicStore/*.csproj ./MvcMusicStore/
COPY MvcMusicStore-Completed/MvcMusicStore/*.config ./MvcMusicStore/
RUN nuget restore
# copy everything else and build app
COPY MvcMusicStore-Completed/MvcMusicStore/. ./MvcMusicStore/
WORKDIR /app/MvcMusicStore
RUN msbuild /p:Configuration=Release -r:False
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 AS runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/MvcMusicStore/. ./
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment