From aaab114a3e544be22e24f1c6fb096bb030989fe2 Mon Sep 17 00:00:00 2001 From: dingo Date: Wed, 22 Apr 2026 19:50:46 -0400 Subject: [PATCH] feat(website): add Dockerfile.website Multi-stage build matching Dockerfile.admin pattern: - Stage 1: restore only changed .csproj files (layer cache), then publish Release build - Stage 2: aspnet:8.0 runtime, non-root appuser, port 8080 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Server/Dockerfile.website | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Server/Dockerfile.website diff --git a/Server/Dockerfile.website b/Server/Dockerfile.website new file mode 100644 index 0000000..ac64b0d --- /dev/null +++ b/Server/Dockerfile.website @@ -0,0 +1,37 @@ +# ── Stage 1: Build ──────────────────────────────────────────────────────────── +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src + +COPY Directory.Build.props Directory.Packages.props ./ +COPY SOR.slnx ./ + +# Copy only the .csproj files first so Docker can cache the restore layer. +# Restore is re-run only when a .csproj or Directory.Packages.props changes. +COPY src/SOR.Website/SOR.Website.csproj src/SOR.Website/ +COPY src/SOR.Database/SOR.Database.csproj src/SOR.Database/ +COPY src/SOR.Shared/SOR.Shared.csproj src/SOR.Shared/ +COPY src/SOR.Networking.Abstractions/SOR.Networking.Abstractions.csproj src/SOR.Networking.Abstractions/ + +RUN dotnet restore src/SOR.Website/SOR.Website.csproj + +# Copy full source (needed for migrations embedded in SOR.Database and wwwroot assets). +COPY . . +RUN dotnet publish src/SOR.Website/SOR.Website.csproj \ + -c Release \ + --no-restore \ + -o /app/publish + +# ── Stage 2: Runtime ────────────────────────────────────────────────────────── +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime +WORKDIR /app + +RUN adduser --disabled-password --gecos "" appuser +USER appuser + +COPY --from=build --chown=appuser:appuser /app/publish . + +EXPOSE 8080 +ENV ASPNETCORE_URLS=http://+:8080 +ENV ASPNETCORE_ENVIRONMENT=Production + +ENTRYPOINT ["dotnet", "SOR.Website.dll"]