Skip to content

Instantly share code, notes, and snippets.

@alwalker
Created July 5, 2021 20:31
Show Gist options
  • Save alwalker/f54a3475cda34cd61c708cd55b3ea5f0 to your computer and use it in GitHub Desktop.
Save alwalker/f54a3475cda34cd61c708cd55b3ea5f0 to your computer and use it in GitHub Desktop.
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["src/MyApp/MyApp.csproj", "src/MyApp/"]
COPY ["src/MyApp/NuGet.Config", "src/MyApp/"]
RUN dotnet restore "src/MyApp/MyApp.csproj"
COPY . .
WORKDIR "/src/src/MyApp"
RUN dotnet build "MyApp.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyApp.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment