# STAGE 1: Build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
# Set the working directory in the container
WORKDIR /app

# Copy the .csproj file and restore any dependencies
# Doing this separately allows Docker to cache this layer
COPY *.csproj ./
RUN dotnet restore

# Copy the rest of the application files
COPY . ./

# Build the application and publish it for production
RUN dotnet publish -c Release -o /app/publish

# STAGE 2: Runtime
# Use the ASP.NET runtime image (much smaller than the SDK)
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
WORKDIR /app

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

# Expose the port your app runs on (usually 8080 in .NET 8+)
EXPOSE 8080

# Set the entrypoint for the application
ENTRYPOINT ["dotnet", "Catalog26.dll"]
