# ── Build stage ────────────────────────────────────────
# Uses the .NET 10 SDK to restore and compile your project.
# Change "MyCobaltApp.csproj" to match your own .csproj filename.
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY MyCobaltApp.csproj ./
RUN dotnet restore
COPY . .
# IMPORTANT: do NOT add -r linux-x64 or --self-contained here.
# Both flatten the runtimes/ folder and break Chromium path resolution.
RUN dotnet publish -c Release --no-restore -o /app/publish

# ── Runtime stage ─────────────────────────────────────
# .NET 10 dropped Debian images — uses Ubuntu 24.04 "Noble" instead.
# Some library names changed with a t64 suffix (e.g. libasound2 → libasound2t64).
FROM mcr.microsoft.com/dotnet/aspnet:10.0-noble AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
    libnss3 libatk1.0-0t64 libatk-bridge2.0-0t64 libcups2t64 \
    libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
    libxrandr2 libgbm1 libpango-1.0-0 libcairo2 \
    libasound2t64 libxshmfence1 libx11-xcb1 \
    libxfixes3 libxss1 libxtst6 \
    fonts-liberation fonts-noto-color-emoji \
    && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/publish .
# Ensure the Chromium binary is executable (NuGet does not preserve Unix permissions).
RUN chmod +x ./runtimes/linux-x64/native/chrome 2>/dev/null || true
# Change "MyCobaltApp.dll" to match your own project name.
ENTRYPOINT ["dotnet", "MyCobaltApp.dll"]
