# Define the SDK to build the project
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app

# Copy the solution and the project files
COPY UI/UI.csproj UI/
COPY *.sln ./

# Restore the dependencies
RUN dotnet restore

# Copy the rest of the source code
COPY UI/ UI/

# Set the working directory to the project directory
WORKDIR /app/UI

# Publish the application
RUN dotnet publish -c Release -o out

# Final stage / runtime
FROM nginx:1.23-alpine
WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

# Copy static assets over
COPY --from=build /app/UI/out/wwwroot .
COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 5023
ENTRYPOINT ["nginx", "-g", "daemon off;"]
