FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["TravelMate.Backend.csproj", "./"]
RUN dotnet restore "TravelMate.Backend.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "TravelMate.Backend.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "TravelMate.Backend.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080
ENTRYPOINT ["dotnet", "TravelMate.Backend.dll"]
