aspnetcore.3.0.Dockerfile.mustache Maven / Gradle / Ivy
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
# Container we use for final publish
FROM mcr.microsoft.com/dotnet/core/aspnet:{{aspnetCoreVersion}}-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# Build container
FROM mcr.microsoft.com/dotnet/core/sdk:{{aspnetCoreVersion}}-buster AS build
# Copy the code into the container
WORKDIR /{{sourceFolder}}
COPY ["{{sourceFolder}}/{{packageName}}/{{packageName}}.csproj", "{{packageName}}/"]
# NuGet restore
RUN dotnet restore "{{packageName}}/{{packageName}}.csproj"
COPY ["{{sourceFolder}}/{{packageName}}/", "{{packageName}}/"]
# Build the API
WORKDIR "{{packageName}}"
RUN dotnet build "{{packageName}}.csproj" -c Release -o /app/build
# Publish it
FROM build AS publish
RUN dotnet publish "{{packageName}}.csproj" -c Release -o /app/publish
# Make the final image for publishing
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{{packageName}}.dll"]