- Add BuildKit cache mounts for NuGet and npm to persist package caches across builds - Skip redundant restore on dotnet publish with --no-restore - Add --prefer-offline to npm ci to prefer cached tarballs - Tag images as randall/backend:latest and randall/frontend:latest via compose image: key Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1.4 KiB
Docker
32 lines
1.4 KiB
Docker
# Build stage
|
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
|
WORKDIR /src
|
|
|
|
# Restore — copy only project files first to cache the NuGet layer
|
|
COPY src/backend/Randall.slnx src/backend/
|
|
COPY src/backend/src/Randall.Domain/Randall.Domain.csproj src/backend/src/Randall.Domain/
|
|
COPY src/backend/src/Randall.Application/Randall.Application.csproj src/backend/src/Randall.Application/
|
|
COPY src/backend/src/Randall.Infrastructure/Randall.Infrastructure.csproj src/backend/src/Randall.Infrastructure/
|
|
COPY src/backend/src/Randall.Api/Randall.Api.csproj src/backend/src/Randall.Api/
|
|
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
|
|
dotnet restore "src/backend/src/Randall.Api/Randall.Api.csproj"
|
|
|
|
# Build — copy source only (no bin/obj/db files)
|
|
COPY src/backend/src/ src/backend/src/
|
|
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
|
|
dotnet publish "src/backend/src/Randall.Api/Randall.Api.csproj" \
|
|
-c Release --no-restore -o /app/publish
|
|
|
|
# Runtime stage
|
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
|
|
WORKDIR /app
|
|
|
|
RUN mkdir -p /app/data
|
|
COPY --from=build /app/publish .
|
|
|
|
ENV ASPNETCORE_URLS=http://+:8080
|
|
ENV ConnectionStrings__DefaultConnection="Data Source=/app/data/randall.db"
|
|
|
|
EXPOSE 8080
|
|
ENTRYPOINT ["dotnet", "Randall.Api.dll"]
|