Table of Contents
This is my sample docker file I use for .net core 3.1 projects.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build
WORKDIR /app
EXPOSE 80
EXPOSE 443
# copy csproj and restore as distinct layers
COPY *.sln .
COPY X.Web/*.*.csproj ./X.Web/
COPY X.Models/*.*.csproj ./X.Models/
COPY X.Data/*.*.csproj ./X.Data/
RUN dotnet restore
# copy everything else and build app
COPY X.Web/. ./X.Web/
COPY X.Models/. ./X.Models/
COPY X.Data/. ./X.Data/
WORKDIR /app/X.Web
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic AS runtime
WORKDIR /app
COPY --from=build /app/X.Web/out ./
ENTRYPOINT ["dotnet", "X.Web.dll"]
This sample has 3 projects in the solution to show how it all ties together.
I mentioned in my other post on Things I've found while Upgrading to .NET Core 3.1 why I switched to Bionic for my base images.