Skip to content

Instantly share code, notes, and snippets.

@fokklz
Created November 1, 2023 13:59
Show Gist options
  • Save fokklz/c6c0bc00169f794d8e1dfa1a79e184cd to your computer and use it in GitHub Desktop.
Save fokklz/c6c0bc00169f794d8e1dfa1a79e184cd to your computer and use it in GitHub Desktop.
Dockerfile for EF-Core Web API (net 0.7)
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["MyWebApi.csproj", ""]
RUN dotnet restore "./MyWebApi.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "MyWebApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyWebApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyWebApi.dll"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment