From f3ac2cbdb020f368785f9eb8b2f3098ec492ec85 Mon Sep 17 00:00:00 2001 From: khwezi Date: Tue, 3 Mar 2026 14:50:12 +0200 Subject: [PATCH] Refactored dockerfile --- Dockerfile | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 85296a5..cc83219 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,12 @@ -#FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base +# Stage 1: Build the app using the SDK +FROM ://mcr.microsoft.com AS build +WORKDIR /src +COPY . . +RUN dotnet publish "SampleApi/SampleApi.csproj" -c Release -o /app/publish -USER app +# Stage 2: Run the app using the Runtime +FROM ://mcr.microsoft.com WORKDIR /app - -EXPOSE 8080 -EXPOSE 8081 - -COPY . /app - -FROM base AS final -WORKDIR /app -ENTRYPOINT ["dotnet", "SampleApi.dll"] \ No newline at end of file +# Copy the compiled files from the 'build' stage to this stage +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "SampleApi.dll"]