From ff3aab8117edbb84706b070a1390fbb2a1b1d69e Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Fri, 27 Jun 2025 15:43:43 +0800 Subject: [PATCH] dopckerfile --- YD_AllHeartRates.Api/Dockerfile | 28 +++++++++++++++++++ .../YD_AllHeartRates.Api.csproj | 2 ++ .../YD_AllHeartRates.Api.AssemblyInfo.cs | 2 +- ...AllHeartRates.Api.AssemblyInfoInputs.cache | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 YD_AllHeartRates.Api/Dockerfile diff --git a/YD_AllHeartRates.Api/Dockerfile b/YD_AllHeartRates.Api/Dockerfile new file mode 100644 index 0000000..5a73c72 --- /dev/null +++ b/YD_AllHeartRates.Api/Dockerfile @@ -0,0 +1,28 @@ + +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base +WORKDIR /app +EXPOSE 80 + + +# 此阶段用于生成服务项目 +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["YD_AllHeartRates.Api/YD_AllHeartRates.Api.Api.csproj", "YD_AllHeartRates.Api/"] +COPY ["YD_AllHeartRates.Api.Commons/YD_AllHeartRates.Api.Commons.csproj", "YD_AllHeartRates.Api.Commons/"] +RUN dotnet restore "./WeChatApplet/YD_AllHeartRates.Api.Api.csproj" +COPY . . +WORKDIR "/src/WeChatApplet" +RUN dotnet build "./YD_AllHeartRates.Api.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# 此阶段用于发布要复制到最终阶段的服务项目 +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./YD_AllHeartRates.Api.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "YD_AllHeartRates.Api.Api.dll"] + diff --git a/YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj b/YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj index ec543cf..0748a2e 100644 --- a/YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj +++ b/YD_AllHeartRates.Api/YD_AllHeartRates.Api.csproj @@ -8,6 +8,8 @@ True obj\Debug\net6.0\YD_AllHeartRates.Api.xml obj\ + Linux + . diff --git a/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfo.cs b/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfo.cs index 6a9726f..bc48b33 100644 --- a/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfo.cs +++ b/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("YD_AllHeartRates.Api")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cba47da79529d88a9c2535c9c0d6a3ad9378b578")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a17b11b80876daa7862ef4b16144c439033d6367")] [assembly: System.Reflection.AssemblyProductAttribute("YD_AllHeartRates.Api")] [assembly: System.Reflection.AssemblyTitleAttribute("YD_AllHeartRates.Api")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfoInputs.cache b/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfoInputs.cache index 36db204..d70720e 100644 --- a/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfoInputs.cache +++ b/YD_AllHeartRates.Api/obj/Debug/net6.0/YD_AllHeartRates.Api.AssemblyInfoInputs.cache @@ -1 +1 @@ -5dadd7f540af7e55599b33b1bde90ec16d8c55e26389806708a87f620f4347bb +acab2b3a1b163e9736087a44792ad6862edd9693f24f76ae003eb8fb0ffe378d