fix(dockerfile): 修正Docker构建流程和文件路径
- 删除多余的目录拷贝,简化COPY指令 - 统一项目文件和配置文件的拷贝路径 - 调整工作目录,避免重复嵌套路径 - 优化dotnet restore和build步骤,确保路径正确 - 保持publish阶段项目路径一致,确保发布成功
This commit is contained in:
parent
8d2eeea982
commit
ca2c0d69a2
23
Dockerfile
23
Dockerfile
@ -7,21 +7,24 @@ EXPOSE 8081
|
|||||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ARG BUILD_CONFIGURATION=Release
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
# Copy Directory.Packages.props for centralized version management
|
|
||||||
|
# Copy project files
|
||||||
COPY ["Directory.Packages.props", "./"]
|
COPY ["Directory.Packages.props", "./"]
|
||||||
COPY ["src/Directory.Packages.props", "src/"]
|
COPY ["YarpGateway.csproj", "./"]
|
||||||
COPY ["src/YarpGateway/YarpGateway.csproj", "src/YarpGateway/"]
|
COPY ["NuGet.Config", "./"]
|
||||||
COPY ["src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Core/Fengling.ServiceDiscovery.Core.csproj", "src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Core/"]
|
|
||||||
COPY ["src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Kubernetes/Fengling.ServiceDiscovery.Kubernetes.csproj", "src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Kubernetes/"]
|
# Restore dependencies
|
||||||
COPY ["src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Static/Fengling.ServiceDiscovery.Static.csproj", "src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Static/"]
|
RUN dotnet restore "YarpGateway.csproj"
|
||||||
RUN dotnet restore "src/YarpGateway/YarpGateway.csproj"
|
|
||||||
|
# Copy all source code
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR "/src/src/YarpGateway"
|
|
||||||
RUN dotnet build "./YarpGateway.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
WORKDIR "/src"
|
||||||
|
RUN dotnet build "YarpGateway.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
FROM build AS publish
|
FROM build AS publish
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ARG BUILD_CONFIGURATION=Release
|
||||||
RUN dotnet publish "./YarpGateway.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
RUN dotnet publish "YarpGateway.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user