# Base image for runtime
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

# Image for building the project
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src

# Copy the .csproj and restore dependencies
COPY ["Aberwyn.csproj", "./"]
RUN dotnet restore "Aberwyn.csproj"

# Copy everything else and build the app
COPY . .
RUN dotnet build "Aberwyn.csproj" -c Release -o /app/build

# Publish the app to the /app/publish folder
FROM build AS publish
RUN dotnet publish "Aberwyn.csproj" -c Release -o /app/publish

# Use the base runtime image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Aberwyn.dll"]
