Refactored docker files to overcome the individually targeted project files

This commit is contained in:
Khwezi Mngoma
2026-06-06 00:16:21 +02:00
parent be6cb422e5
commit 8a5d55fc2a
3 changed files with 43 additions and 21 deletions
+15 -8
View File
@@ -6,16 +6,23 @@ EXPOSE 443
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ARG TARGETARCH
WORKDIR /src
COPY ["src/LiteCharmsSecurity.Admin.Api/LiteCharmsSecurity.Admin.Api.csproj", "src/LiteCharmsSecurity.Admin.Api/"]
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.Shared/LiteCharmsSecurity.Admin.EntityFramework.Shared.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.Shared/"]
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.SqlServer/LiteCharmsSecurity.Admin.EntityFramework.SqlServer.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.SqlServer/"]
COPY ["src/LiteCharmsSecurity.Shared/LiteCharmsSecurity.Shared.csproj", "src/LiteCharmsSecurity.Shared/"]
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL/"]
RUN dotnet restore "src/LiteCharmsSecurity.Admin.Api/LiteCharmsSecurity.Admin.Api.csproj"
# 1. Copy the master solution file and structural project footprints.
# Wildcard matching reads everything cleanly into the build cache layer.
COPY LiteCharmsSecurity.sln ./
COPY src/*/*.csproj ./
COPY src/ ./src/
# Clean up duplicate files dropped into the root context by the wildcard copy
RUN rm -f *.csproj
# 2. Restore the entire solution using the global solution profile
RUN dotnet restore "LiteCharmsSecurity.sln"
# 3. Bring in the rest of your implementation logic code files
COPY . .
WORKDIR "src/LiteCharmsSecurity.Admin.Api"
# 4. Target your specific Admin API project path for Compilation & Publishing
WORKDIR "/src/src/LiteCharmsSecurity.Admin.Api"
RUN dotnet build "LiteCharmsSecurity.Admin.Api.csproj" -c Release -o /app/build
FROM build AS publish
@@ -25,4 +32,4 @@ FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENTRYPOINT ["dotnet", "LiteCharmsSecurity.Admin.Api.dll"]
ENTRYPOINT ["dotnet", "LiteCharmsSecurity.Admin.Api.dll"]