#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/NPin.Web/NPin.Web.csproj", "src/NPin.Web/"]
COPY ["framework/NPin.Framework.AspNetCore.Authentication.OAuth/NPin.Framework.AspNetCore.Authentication.OAuth.csproj", "framework/NPin.Framework.AspNetCore.Authentication.OAuth/"]
COPY ["framework/NPin.Framework.AspNetCore/NPin.Framework.AspNetCore.csproj", "framework/NPin.Framework.AspNetCore/"]
COPY ["framework/NPin.Framework.Core/NPin.Framework.Core.csproj", "framework/NPin.Framework.Core/"]
COPY ["src/NPin.Application/NPin.Application.csproj", "src/NPin.Application/"]
COPY ["framework/NPin.Framework.Ddd.Application/NPin.Framework.Ddd.Application.csproj", "framework/NPin.Framework.Ddd.Application/"]
COPY ["framework/NPin.Framework.Ddd.Application.Contracts/NPin.Framework.Ddd.Application.Contracts.csproj", "framework/NPin.Framework.Ddd.Application.Contracts/"]
COPY ["module/bbs/NPin.Framework.Bbs.Application/NPin.Framework.Bbs.Application.csproj", "module/bbs/NPin.Framework.Bbs.Application/"]
COPY ["module/rbac/NPin.Framework.Rbac.Application/NPin.Framework.Rbac.Application.csproj", "module/rbac/NPin.Framework.Rbac.Application/"]
COPY ["module/rbac/NPin.Framework.Rbac.Application.Contracts/NPin.Framework.Rbac.Application.Contracts.csproj", "module/rbac/NPin.Framework.Rbac.Application.Contracts/"]
COPY ["module/rbac/NPin.Framework.Rbac.Domain.Shared/NPin.Framework.Rbac.Domain.Shared.csproj", "module/rbac/NPin.Framework.Rbac.Domain.Shared/"]
COPY ["framework/NPin.Framework.Mapster/NPin.Framework.Mapster.csproj", "framework/NPin.Framework.Mapster/"]
COPY ["framework/NPin.Framework.SqlSugarCore.Abstractions/NPin.Framework.SqlSugarCore.Abstractions.csproj", "framework/NPin.Framework.SqlSugarCore.Abstractions/"]
COPY ["module/rbac/NPin.Framework.Rbac.Domain/NPin.Framework.Rbac.Domain.csproj", "module/rbac/NPin.Framework.Rbac.Domain/"]
COPY ["module/bbs/NPin.Framework.Bbs.Application.Contracts/NPin.Framework.Bbs.Application.Contracts.csproj", "module/bbs/NPin.Framework.Bbs.Application.Contracts/"]
COPY ["module/bbs/NPin.Framework.Bbs.Domain.Shared/NPin.Framework.Bbs.Domain.Shared.csproj", "module/bbs/NPin.Framework.Bbs.Domain.Shared/"]
COPY ["module/bbs/NPin.Framework.Bbs.Domain/NPin.Framework.Bbs.Domain.csproj", "module/bbs/NPin.Framework.Bbs.Domain/"]
COPY ["src/NPin.Application.Contracts/NPin.Application.Contracts.csproj", "src/NPin.Application.Contracts/"]
COPY ["src/NPin.Domain.Shared/NPin.Domain.Shared.csproj", "src/NPin.Domain.Shared/"]
COPY ["src/NPin.Domain/NPin.Domain.csproj", "src/NPin.Domain/"]
COPY ["src/NPin.SqlSugarCore/NPin.SqlSugarCore.csproj", "src/NPin.SqlSugarCore/"]
COPY ["framework/NPin.Framework.SqlSugarCore/NPin.Framework.SqlSugarCore.csproj", "framework/NPin.Framework.SqlSugarCore/"]
COPY ["module/bbs/NPin.Framework.Bbs.SqlSugarCore/NPin.Framework.Bbs.SqlSugarCore.csproj", "module/bbs/NPin.Framework.Bbs.SqlSugarCore/"]
COPY ["module/rbac/NPin.Framework.Rbac.SqlSugarCore/NPin.Framework.Rbac.SqlSugarCore.csproj", "module/rbac/NPin.Framework.Rbac.SqlSugarCore/"]
RUN dotnet restore "./src/NPin.Web/./NPin.Web.csproj"
COPY . .
WORKDIR "/src/src/NPin.Web"
RUN dotnet build "./NPin.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./NPin.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "NPin.Web.dll"]