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

COPY ["Kalaha.Frontend/Kalaha.Frontend.csproj", "Kalaha.Frontend/"]
RUN dotnet restore "Kalaha.Frontend/Kalaha.Frontend.csproj"

COPY Kalaha.Frontend/ Kalaha.Frontend/
WORKDIR "/src/Kalaha.Frontend"
RUN dotnet publish "Kalaha.Frontend.csproj" -c Release -o /app/publish

# 2. Serve-Phase
FROM nginx:alpine AS final
WORKDIR /usr/share/nginx/html

RUN rm -rf ./*
COPY --from=build /app/publish/wwwroot .

RUN echo "server { listen 80; location / { root /usr/share/nginx/html; try_files \$uri \$uri/ /index.html; } }" > /etc/nginx/conf.d/default.conf

EXPOSE 80
