Refactored docker files to overcome the individually targeted project files
This commit is contained in:
@@ -6,14 +6,23 @@ EXPOSE 443
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
ARG TARGETARCH
|
||||
WORKDIR /src
|
||||
COPY ["src/LiteCharmsSecurity.STS.Identity/LiteCharmsSecurity.STS.Identity.csproj", "src/LiteCharmsSecurity.STS.Identity/"]
|
||||
COPY ["src/LiteCharmsSecurity.Admin.EntityFramework.Shared/LiteCharmsSecurity.Admin.EntityFramework.Shared.csproj", "src/LiteCharmsSecurity.Admin.EntityFramework.Shared/"]
|
||||
COPY ["src/LiteCharmsSecurity.Shared/LiteCharmsSecurity.Shared.csproj", "src/LiteCharmsSecurity.Shared/"]
|
||||
|
||||
RUN dotnet restore "src/LiteCharmsSecurity.STS.Identity/LiteCharmsSecurity.STS.Identity.csproj"
|
||||
# 1. Copy the master solution file and the entire project directory structures
|
||||
# but ONLY copy the .csproj files. This keeps the Docker layer cache completely optimization-friendly.
|
||||
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 cleanly using the global workspace cache
|
||||
RUN dotnet restore "LiteCharmsSecurity.sln"
|
||||
|
||||
# 3. Bring in the rest of your implementation code files now that the packages are fully cached
|
||||
COPY . .
|
||||
WORKDIR "src/LiteCharmsSecurity.STS.Identity"
|
||||
|
||||
# 4. Target your specific project execution path for Compilation & Publishing
|
||||
WORKDIR "/src/src/LiteCharmsSecurity.STS.Identity"
|
||||
RUN dotnet build "LiteCharmsSecurity.STS.Identity.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
|
||||
Reference in New Issue
Block a user