FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app

# Copy solution and projects
COPY ClassNotify.sln .
COPY src/Shared/ClassNotify.Shared/ src/Shared/ClassNotify.Shared/
COPY src/Server/ClassNotify.Server/ src/Server/ClassNotify.Server/

# Restore and build Server
RUN dotnet restore src/Server/ClassNotify.Server/ClassNotify.Server.csproj
RUN dotnet publish src/Server/ClassNotify.Server/ClassNotify.Server.csproj -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .

ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000

ENTRYPOINT ["dotnet", "ClassNotify.Server.dll"]
