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

# Copy csproj files and restore
COPY ["MyNewProjectName.Domain/MyNewProjectName.Domain.csproj", "MyNewProjectName.Domain/"]
COPY ["MyNewProjectName.Contracts/MyNewProjectName.Contracts.csproj", "MyNewProjectName.Contracts/"]
COPY ["MyNewProjectName.Application/MyNewProjectName.Application.csproj", "MyNewProjectName.Application/"]
COPY ["MyNewProjectName.Infrastructure/MyNewProjectName.Infrastructure.csproj", "MyNewProjectName.Infrastructure/"]
COPY ["MyNewProjectName.WebAPI/MyNewProjectName.WebAPI.csproj", "MyNewProjectName.WebAPI/"]

RUN dotnet restore "MyNewProjectName.WebAPI/MyNewProjectName.WebAPI.csproj"

# Copy everything else and build
COPY . .
WORKDIR "/src/MyNewProjectName.WebAPI"
RUN dotnet build "MyNewProjectName.WebAPI.csproj" -c Release -o /app/build

# Publish stage
FROM build AS publish
RUN dotnet publish "MyNewProjectName.WebAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false

# Final stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyNewProjectName.WebAPI.dll"]
