# ── Build stage ────────────────────────────────────────────────
FROM mcr.microsoft.com/dotnet/sdk@sha256:8a90a473da5205a16979de99d2fc20975e922c68304f5c79d564e666dc3982fc AS build
WORKDIR /repo

# Restore dependencies (cached layer — only re-runs on .csproj change)
COPY planli.frontend/planli.frontend/planli.frontend.csproj \
     planli.frontend/planli.frontend/
RUN dotnet restore planli.frontend/planli.frontend/planli.frontend.csproj

# Copy source and publish
COPY planli.frontend/planli.frontend/ planli.frontend/planli.frontend/
RUN dotnet publish planli.frontend/planli.frontend/planli.frontend.csproj \
    -c Release \
    -o /publish \
    -p:BlazorEnableCompression=false \
    --nologo

# ── Runtime stage ──────────────────────────────────────────────
FROM nginx@sha256:4f15ae9562a7d03826a0c06d51cf5f628b52944ef5f5d90ab01723f843f4d8fa
COPY --from=build /publish/wwwroot         /usr/share/nginx/html
COPY planli.frontend/planli.frontend/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
