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

# Copy the project file and restore dependencies
COPY PosterMaker.Core.csproj .
RUN dotnet restore PosterMaker.Core.csproj

# Copy the entire source code and build it
COPY . .
RUN dotnet build PosterMaker.Core.csproj -c Release -o /app/build

# Stage 2: Publish
FROM build AS publish
RUN dotnet publish PosterMaker.Core.csproj -c Release -o /app/publish

# Stage 3: Final
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS final
WORKDIR /app

# Set environment variables and expose port
ENV ASPNETCORE_URLS=http://+:80
EXPOSE 80

# Copy the published app from the publish stage
COPY --from=publish /app/publish .

# Set the entrypoint
ENTRYPOINT ["dotnet", "PosterMaker.Core.dll"]