28 lines
698 B
Docker
28 lines
698 B
Docker
# ---------- Build stage ----------
|
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
WORKDIR /src
|
|
|
|
# Restore first to leverage Docker layer caching.
|
|
COPY ["MealPlan.Api.csproj", "./"]
|
|
RUN dotnet restore "MealPlan.Api.csproj"
|
|
|
|
COPY . .
|
|
RUN dotnet publish "MealPlan.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
|
|
# ---------- Runtime stage ----------
|
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
|
|
WORKDIR /app
|
|
|
|
# Run as the non-root user shipped in the aspnet image.
|
|
USER $APP_UID
|
|
|
|
ENV ASPNETCORE_URLS=http://+:5000 \
|
|
ASPNETCORE_ENVIRONMENT=Production \
|
|
DOTNET_RUNNING_IN_CONTAINER=true
|
|
|
|
EXPOSE 5000
|
|
|
|
COPY --from=build /app/publish .
|
|
|
|
ENTRYPOINT ["dotnet", "MealPlan.Api.dll"]
|