diff --git a/Dockerfile b/Dockerfile index 3442a56..dfa6b81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,21 +7,24 @@ EXPOSE 8081 FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src -# Copy Directory.Packages.props for centralized version management + +# Copy project files COPY ["Directory.Packages.props", "./"] -COPY ["src/Directory.Packages.props", "src/"] -COPY ["src/YarpGateway/YarpGateway.csproj", "src/YarpGateway/"] -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/"] -COPY ["src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Static/Fengling.ServiceDiscovery.Static.csproj", "src/Fengling.ServiceDiscovery/Fengling.ServiceDiscovery.Static/"] -RUN dotnet restore "src/YarpGateway/YarpGateway.csproj" +COPY ["YarpGateway.csproj", "./"] +COPY ["NuGet.Config", "./"] + +# Restore dependencies +RUN dotnet restore "YarpGateway.csproj" + +# Copy all source code 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 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 WORKDIR /app