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
+14 -8
View File
@@ -11,22 +11,28 @@ ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 \
NUGET_XMLDOC_MODE=skip
WORKDIR /src
# Bring over Node & NPM runtimes for administrative UI asset packaging steps
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
&& npm install -g npm@latest \
&& node --version && npm --version
COPY ["src/LiteCharmsSecurity.Admin/LiteCharmsSecurity.Admin.csproj", "src/LiteCharmsSecurity.Admin/"]
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.PostgreSQL/"]
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/"]
# 1. Copy the master solution file and project structures for build cache retention
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
RUN dotnet restore "src/LiteCharmsSecurity.Admin/LiteCharmsSecurity.Admin.csproj"
# 2. Restore the entire solution cleanly via public NuGet paths
RUN dotnet restore "LiteCharmsSecurity.sln"
# 3. Pull in the remaining implementation files
COPY . .
WORKDIR "src/LiteCharmsSecurity.Admin"
# 4. Navigate into your specific Admin UI directory context for assembly compilation
WORKDIR "/src/src/LiteCharmsSecurity.Admin"
RUN dotnet build "LiteCharmsSecurity.Admin.csproj" -c Release -o /app/build
FROM build AS publish
@@ -36,4 +42,4 @@ FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENTRYPOINT ["dotnet", "LiteCharmsSecurity.Admin.dll"]
ENTRYPOINT ["dotnet", "LiteCharmsSecurity.Admin.dll"]