﻿# [备用] CI 已改用: dotnet publish /t:PublishContainer（见 cicd/）
# 多阶段构建（在 build 节点用 Docker 执行，勿用 Kaniko 解大 SDK）
# CI: docker build --build-arg NUGET_IDESHIP=https://baget.ideship.com/v3/index.json ...
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src

ARG NUGET_IDESHIP=https://baget.ideship.com/v3/index.json

COPY ["NuGet.Config", "Directory.Build.props", "./"]
RUN sed -i \
      -e "s|https://baget.ideship.com/v3/index.json|${NUGET_IDESHIP}|g" \
      -e "s|http://baget.ideship.com/v3/index.json|${NUGET_IDESHIP}|g" \
      NuGet.Config \
    && cat NuGet.Config

COPY ["src/InterfaceForward.Domain.Shared/InterfaceForward.Domain.Shared.csproj", "src/InterfaceForward.Domain.Shared/"]
COPY ["src/InterfaceForward.Application.Contracts/InterfaceForward.Application.Contracts.csproj", "src/InterfaceForward.Application.Contracts/"]
COPY ["src/InterfaceForward.Repositories/InterfaceForward.Repositories.csproj", "src/InterfaceForward.Repositories/"]
COPY ["src/InterfaceForward.Application/InterfaceForward.Application.csproj", "src/InterfaceForward.Application/"]
COPY ["src/InterfaceForward.Api/InterfaceForward.Api.csproj", "src/InterfaceForward.Api/"]
RUN dotnet restore "src/InterfaceForward.Api/InterfaceForward.Api.csproj"

COPY . .
WORKDIR /src/src/InterfaceForward.Api
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "InterfaceForward.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "InterfaceForward.Api.dll"]
