Compare commits
No commits in common. "f45168f0477ab7a0d5721366f19ea67c48189d39" and "93224fdea294364fcc07f8afa61055eee64955b2" have entirely different histories.
f45168f047
...
93224fdea2
@ -1,8 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<packageSources>
|
<packageSources>
|
||||||
<clear />
|
|
||||||
<add key="ideship" value="https://baget.ideship.com/v3/index.json" />
|
<add key="ideship" value="https://baget.ideship.com/v3/index.json" />
|
||||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
||||||
</packageSources>
|
</packageSources>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -1,35 +1,24 @@
|
|||||||
# 构建上下文 = 仓库根目录(含 NuGet.Config / Directory.Build.props / src/)
|
# ===== 阶段1: 基础依赖层(可缓存) =====
|
||||||
# Kaniko 默认: --build-arg=NUGET_IDESHIP=http://baget/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
|
# ✅ 关键优化:只复制 .csproj 文件,让 restore 层可以缓存
|
||||||
|
|
||||||
COPY ["NuGet.Config", "Directory.Build.props", "./"]
|
|
||||||
# 集群内构建走 Service;本机构建可 --build-arg=NUGET_IDESHIP=https://baget.ideship.com/v3/index.json
|
|
||||||
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/"]
|
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"
|
||||||
|
|
||||||
|
# ===== 阶段2: 构建层 =====
|
||||||
|
# ✅ 现在才复制所有代码(这一层变动频繁,但 restore 已经跑完了)
|
||||||
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
|
RUN dotnet build "InterfaceForward.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
# ===== 阶段3: 发布层 =====
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
ARG BUILD_CONFIGURATION=Release
|
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
|
||||||
|
|
||||||
|
# ===== 阶段4: 最终运行时(轻量级) =====
|
||||||
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=publish /app/publish .
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user