This commit is contained in:
xiaolipro 2026-09-04 16:13:37 +08:00
parent f45168f047
commit eb03733676
2 changed files with 13 additions and 10 deletions

View File

@ -1,12 +1,12 @@
# 构建上下文 = 仓库根目录(含 NuGet.Config / Directory.Build.props / src/ # [备用] CI 已改用: dotnet publish /t:PublishContainer见 cicd/
# Kaniko 默认: --build-arg=NUGET_IDESHIP=http://baget/v3/index.json # 多阶段构建(在 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 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src WORKDIR /src
ARG NUGET_IDESHIP=http://baget/v3/index.json ARG NUGET_IDESHIP=https://baget.ideship.com/v3/index.json
COPY ["NuGet.Config", "Directory.Build.props", "./"] COPY ["NuGet.Config", "Directory.Build.props", "./"]
# 集群内构建走 Service本机构建可 --build-arg=NUGET_IDESHIP=https://baget.ideship.com/v3/index.json
RUN sed -i \ RUN sed -i \
-e "s|https://baget.ideship.com/v3/index.json|${NUGET_IDESHIP}|g" \ -e "s|https://baget.ideship.com/v3/index.json|${NUGET_IDESHIP}|g" \
-e "s|http://baget.ideship.com/v3/index.json|${NUGET_IDESHIP}|g" \ -e "s|http://baget.ideship.com/v3/index.json|${NUGET_IDESHIP}|g" \
@ -18,19 +18,14 @@ COPY ["src/InterfaceForward.Application.Contracts/InterfaceForward.Application.C
COPY ["src/InterfaceForward.Repositories/InterfaceForward.Repositories.csproj", "src/InterfaceForward.Repositories/"] COPY ["src/InterfaceForward.Repositories/InterfaceForward.Repositories.csproj", "src/InterfaceForward.Repositories/"]
COPY ["src/InterfaceForward.Application/InterfaceForward.Application.csproj", "src/InterfaceForward.Application/"] COPY ["src/InterfaceForward.Application/InterfaceForward.Application.csproj", "src/InterfaceForward.Application/"]
COPY ["src/InterfaceForward.Api/InterfaceForward.Api.csproj", "src/InterfaceForward.Api/"] COPY ["src/InterfaceForward.Api/InterfaceForward.Api.csproj", "src/InterfaceForward.Api/"]
RUN dotnet restore "src/InterfaceForward.Api/InterfaceForward.Api.csproj" RUN dotnet restore "src/InterfaceForward.Api/InterfaceForward.Api.csproj"
COPY . . COPY . .
WORKDIR /src/src/InterfaceForward.Api WORKDIR /src/src/InterfaceForward.Api
ARG BUILD_CONFIGURATION=Release ARG BUILD_CONFIGURATION=Release
RUN dotnet build "InterfaceForward.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build --no-restore
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "InterfaceForward.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false --no-restore 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 FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app WORKDIR /app
COPY --from=publish /app/publish . COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "InterfaceForward.Api.dll"] ENTRYPOINT ["dotnet", "InterfaceForward.Api.dll"]

View File

@ -5,8 +5,16 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<!-- dotnet publish /t:PublishContainer -->
<EnableSdkContainerSupport>true</EnableSdkContainerSupport>
<ContainerBaseImage>mcr.microsoft.com/dotnet/aspnet:8.0</ContainerBaseImage>
<ContainerWorkingDirectory>/app</ContainerWorkingDirectory>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ContainerPort Include="8888" Type="tcp" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" /> <ProjectReference Include="..\InterfaceForward.Application\InterfaceForward.Application.csproj" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" /> <PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />