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

COPY CommercialEventHub.CustomerPortal.sln .
COPY src/CommercialEventHub.CustomerPortal.Domain/CommercialEventHub.CustomerPortal.Domain.csproj src/CommercialEventHub.CustomerPortal.Domain/
COPY src/CommercialEventHub.CustomerPortal.Application/CommercialEventHub.CustomerPortal.Application.csproj src/CommercialEventHub.CustomerPortal.Application/
COPY src/CommercialEventHub.CustomerPortal.Infrastructure/CommercialEventHub.CustomerPortal.Infrastructure.csproj src/CommercialEventHub.CustomerPortal.Infrastructure/
COPY src/CommercialEventHub.CustomerPortal.Web/CommercialEventHub.CustomerPortal.Web.csproj src/CommercialEventHub.CustomerPortal.Web/
RUN dotnet restore

COPY . .
RUN dotnet publish src/CommercialEventHub.CustomerPortal.Web/CommercialEventHub.CustomerPortal.Web.csproj -c Release -o /app/publish

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

# Persist protected uploads and the SQLite database outside the image layers.
VOLUME ["/app/App_Data"]

ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
ENTRYPOINT ["dotnet", "CommercialEventHub.CustomerPortal.Web.dll"]
