# ---- Build stage: compile and publish with the full SDK ----
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src

# Restore first (cached unless the project file changes).
COPY src/WishNinja/WishNinja.csproj src/WishNinja/
RUN dotnet restore src/WishNinja/WishNinja.csproj

# Build + publish.
COPY src/ src/
RUN dotnet publish src/WishNinja/WishNinja.csproj -c Release -o /app /p:UseAppHost=false

# ---- Runtime stage: ship only the ASP.NET Core runtime ----
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app

# Listen on 8080 (no TLS — terminate TLS at your reverse proxy) and keep all
# mutable state under /data so a single volume persists db, uploads and keys.
ENV ASPNETCORE_HTTP_PORTS=8080 \
    WishNinja__DataPath=/data

RUN mkdir -p /data
VOLUME /data
EXPOSE 8080

COPY --from=build /app .
ENTRYPOINT ["dotnet", "WishNinja.dll"]
