# ProostenKrant — Blazor Server + LaTeX
# De texlive-installatie staat in een eigen, vroege laag van de runtime-image,
# zodat app-wijzigingen de (trage) LaTeX-installatie niet opnieuw triggeren.

# ---------- Build ----------
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src

COPY src/ProostenKrant/ProostenKrant.csproj ./ProostenKrant/
RUN dotnet restore ProostenKrant/ProostenKrant.csproj

COPY src/ProostenKrant/ ./ProostenKrant/
RUN dotnet publish ProostenKrant/ProostenKrant.csproj -c Release -o /app/publish

# ---------- Runtime ----------
FROM mcr.microsoft.com/dotnet/aspnet:10.0

# LaTeX (eenmalig geinstalleerd, daarna door Docker-laagcache stabiel)
RUN apt-get update && apt-get install -y --no-install-recommends \
        texlive-latex-base \
        texlive-latex-recommended \
        texlive-latex-extra \
        texlive-fonts-recommended \
        texlive-fonts-extra \
        texlive-publishers \
        texlive-pictures \
        texlive-lang-european \
        ghostscript \
    && rm -rf /var/lib/apt/lists/*

# binhex.tex (nodig voor newtx) zit in texlive-plain-generic.
# Aparte laag: wijzigingen hierboven herinstalleren de grote texlive-laag niet.
RUN apt-get update && apt-get install -y --no-install-recommends \
        texlive-plain-generic \
    && rm -rf /var/lib/apt/lists/*

ENV ASPNETCORE_URLS=http://+:8080 \
    ASPNETCORE_ENVIRONMENT=Production

WORKDIR /app
COPY --from=build /app/publish .

RUN mkdir -p /app/wwwroot/resources/images/profiles /app/wwwroot/resources/images/articles /app/archive

EXPOSE 8080
ENTRYPOINT ["dotnet", "ProostenKrant.dll"]
