# ============================
# BUILD + DOCFX GENERATION
# ============================
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

# Install DocFX (global tool)
RUN dotnet tool install -g docfx
ENV PATH="$PATH:/root/.dotnet/tools"

WORKDIR /src

# Copy entire project
COPY . .

# STEP 1: Build your ASP/SDK project
RUN dotnet publish -c Release -o /app/publish

# STEP 2: Generate API docs (DocFX)
# Assumes DocFX config is in /src/docs/docfx.json
RUN docfx docs/docfx.json


# ============================
# RUNTIME (clean, lightweight)
# ============================
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app

# Copy application binaries
COPY --from=build /app/publish .

# Copy generated documentation into wwwroot/docs
COPY --from=build /src/docs/_site ./wwwroot/docs

ENTRYPOINT ["dotnet", "MaksuSDK.dll"]