# ── Stage 1: Build ──────────────────────────────────────────────────────────── # Uses the full SDK image; output is a self-contained publish artifact. FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /src # Copy solution props first — these rarely change so the layer is cached. COPY Directory.Build.props Directory.Packages.props ./ COPY SOR.slnx ./ # Copy individual csproj files so 'dotnet restore' is a separate cached layer. # Only invalidated when a dependency changes, not when source changes. COPY src/SOR.Host/SOR.Host.csproj src/SOR.Host/ COPY src/SOR.Auth/SOR.Auth.csproj src/SOR.Auth/ COPY src/SOR.Bazaar/SOR.Bazaar.csproj src/SOR.Bazaar/ COPY src/SOR.Cdn/SOR.Cdn.csproj src/SOR.Cdn/ COPY src/SOR.Chat/SOR.Chat.csproj src/SOR.Chat/ COPY src/SOR.Collection/SOR.Collection.csproj src/SOR.Collection/ COPY src/SOR.Content/SOR.Content.csproj src/SOR.Content/ COPY src/SOR.Database/SOR.Database.csproj src/SOR.Database/ COPY src/SOR.Gateway/SOR.Gateway.csproj src/SOR.Gateway/ COPY src/SOR.Networking.Abstractions/SOR.Networking.Abstractions.csproj src/SOR.Networking.Abstractions/ COPY src/SOR.Networking.Nats/SOR.Networking.Nats.csproj src/SOR.Networking.Nats/ COPY src/SOR.Networking.Redis/SOR.Networking.Redis.csproj src/SOR.Networking.Redis/ COPY src/SOR.Networking.WebSocket/SOR.Networking.WebSocket.csproj src/SOR.Networking.WebSocket/ COPY src/SOR.Matchmaking/SOR.Matchmaking.csproj src/SOR.Matchmaking/ COPY src/SOR.Game/SOR.Game.csproj src/SOR.Game/ COPY src/SOR.Shared/SOR.Shared.csproj src/SOR.Shared/ COPY src/SOR.Shared.Proto/SOR.Shared.Proto.csproj src/SOR.Shared.Proto/ COPY src/SOR.Versioning/SOR.Versioning.csproj src/SOR.Versioning/ COPY src/SOR.Support/SOR.Support.csproj src/SOR.Support/ RUN dotnet restore src/SOR.Host/SOR.Host.csproj # Copy full source and publish. COPY . . RUN dotnet publish src/SOR.Host/SOR.Host.csproj \ -c Release \ --no-restore \ -o /app/publish # ── Stage 2: Runtime ────────────────────────────────────────────────────────── FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime WORKDIR /app # Run as non-root for security. 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.Host.dll"]