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

# Install Python (required for AOT compilation)
RUN apt-get update && \
    apt-get install -y python3 && \
    ln -s /usr/bin/python3 /usr/bin/python

# Install required workloads
RUN dotnet workload install wasm-tools

# Copy project and solution files
COPY *.csproj ./
RUN dotnet restore

# Copy the rest of the application
COPY . .

# Publish the app
RUN dotnet publish -c Release -o /app/publish

# Runtime stage: Use Nginx to serve static files
FROM nginx:alpine
COPY --from=build /app/publish/wwwroot /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
