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

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

RUN dotnet restore "iYHCT360.AdminAPI/iYHCT360.AdminAPI.csproj"

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

# Publish stage
FROM build AS publish
RUN dotnet publish "iYHCT360.AdminAPI.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", "iYHCT360.AdminAPI.dll"]
