diff --git a/Dockerfile.api b/Dockerfile.api new file mode 100644 index 0000000..14271f8 --- /dev/null +++ b/Dockerfile.api @@ -0,0 +1,26 @@ +# Stage 1: Build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src + +# Copy project files and restore (layer-cached separately for faster rebuilds) +COPY BudgetApp.Api/BudgetApp.Api.csproj BudgetApp.Api/ +COPY BudgetApp.Storage/BudgetApp.Storage.csproj BudgetApp.Storage/ +COPY BudgetApp.Services/BudgetApp.Services.csproj BudgetApp.Services/ +COPY BudgetApp.PublicModels/BudgetApp.PublicModels.csproj BudgetApp.PublicModels/ +COPY BudgetApp.Enums/BudgetApp.Enums.csproj BudgetApp.Enums/ +RUN dotnet restore BudgetApp.Api/BudgetApp.Api.csproj + +# Copy source and publish +COPY BudgetApp.Api/ BudgetApp.Api/ +COPY BudgetApp.Storage/ BudgetApp.Storage/ +COPY BudgetApp.Services/ BudgetApp.Services/ +COPY BudgetApp.PublicModels/ BudgetApp.PublicModels/ +COPY BudgetApp.Enums/ BudgetApp.Enums/ +RUN dotnet publish BudgetApp.Api/BudgetApp.Api.csproj -c Release -o /app/publish --no-restore + +# Stage 2: Runtime +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime +WORKDIR /app +COPY --from=build /app/publish . +EXPOSE 8080 +ENTRYPOINT ["dotnet", "BudgetApp.Api.dll"]