Simplify Dockerfile: copy all from src/ parent dir

This commit is contained in:
masoud
2025-12-06 15:09:15 +00:00
parent 44b87ecf50
commit 57f73e3dcc

View File

@@ -1,28 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src WORKDIR /src
# Copy NuGet config # Copy everything from parent directory (src/)
COPY NuGet.config ./ COPY ../ ./
# Copy solution file # Restore using NuGet.config in WebApi folder
COPY ../FrontOffice.BFF.sln ./ RUN dotnet restore "FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj" --configfile FrontOffice.BFF.WebApi/NuGet.config
# Copy all project files
COPY FrontOffice.BFF.WebApi.csproj ./FrontOffice.BFF.WebApi/
COPY ../FrontOffice.BFF.Application/*.csproj ./FrontOffice.BFF.Application/
COPY ../FrontOffice.BFF.Infrastructure/*.csproj ./FrontOffice.BFF.Infrastructure/
COPY ../FrontOffice.BFF.Domain/*.csproj ./FrontOffice.BFF.Domain/
COPY ../Protobufs/*/*.csproj ./Protobufs/
# Restore with NuGet.config
RUN dotnet restore "FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj" --configfile NuGet.config
# Copy all source code
COPY . ./FrontOffice.BFF.WebApi/
COPY ../FrontOffice.BFF.Application/ ./FrontOffice.BFF.Application/
COPY ../FrontOffice.BFF.Infrastructure/ ./FrontOffice.BFF.Infrastructure/
COPY ../FrontOffice.BFF.Domain/ ./FrontOffice.BFF.Domain/
COPY ../Protobufs/ ./Protobufs/
# Build and publish # Build and publish
RUN dotnet publish "FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj" -c Release -o /app/publish --no-restore RUN dotnet publish "FrontOffice.BFF.WebApi/FrontOffice.BFF.WebApi.csproj" -c Release -o /app/publish --no-restore