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

# Copy project file and restore dependencies
COPY BlazorApp/SilverLabs.Website.csproj BlazorApp/
RUN dotnet restore "BlazorApp/SilverLabs.Website.csproj"

# Copy all source files
COPY BlazorApp/ BlazorApp/

# Build and publish the application
WORKDIR /src/BlazorApp
RUN dotnet publish "SilverLabs.Website.csproj" -c Release -o /app/publish

# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0

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

# Expose port 80
EXPOSE 80

# Set environment to production
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+:80

# Start the Blazor application
ENTRYPOINT ["dotnet", "SilverLabs.Website.dll"]
