diff --git a/src/Thor.Service/Dockerfile b/src/Thor.Service/Dockerfile index e031fda..d17ef58 100644 --- a/src/Thor.Service/Dockerfile +++ b/src/Thor.Service/Dockerfile @@ -1,10 +1,12 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。 + +# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base USER root RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN echo "Asia/Shanghai" > /etc/timezone WORKDIR /app EXPOSE 8080 -EXPOSE 8081 FROM node as lobe WORKDIR /src @@ -13,9 +15,12 @@ RUN yarn RUN npm i RUN yarn run build -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build + +# 此阶段用于生成服务项目 +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src +COPY ["Directory.Build.props", "."] COPY ["src/Thor.Service/Thor.Service.csproj", "src/Thor.Service/"] COPY ["src/extensions/Thor.AzureOpenAI/Thor.AzureOpenAI.csproj", "src/extensions/Thor.AzureOpenAI/"] COPY ["src/Thor.Abstractions/Thor.Abstractions.csproj", "src/Thor.Abstractions/"] @@ -32,30 +37,33 @@ COPY ["src/extensions/Thor.Qiansail/Thor.Qiansail.csproj", "src/extensions/Thor. COPY ["src/extensions/Thor.SparkDesk/Thor.SparkDesk.csproj", "src/extensions/Thor.SparkDesk/"] COPY ["src/framework/Thor.BuildingBlocks.Cache/Thor.BuildingBlocks.Cache.csproj", "src/framework/Thor.BuildingBlocks.Cache/"] COPY ["src/framework/Thor.BuildingBlocks.Event/Thor.BuildingBlocks.Event.csproj", "src/framework/Thor.BuildingBlocks.Event/"] -COPY ["src/Provider/Thor.Provider.DM/Thor.Provider.DM.csproj", "src/Provider/Thor.Provider.DM/"] -COPY ["src/Thor.Infrastructure/Thor.Infrastructure.csproj", "src/Thor.Infrastructure/"] -COPY ["src/Thor.Domain/Thor.Domain.csproj", "src/Thor.Domain/"] -COPY ["src/Thor.Core/Thor.Core.csproj", "src/Thor.Core/"] COPY ["src/framework/Thor.LocalEvent/Thor.LocalEvent.csproj", "src/framework/Thor.LocalEvent/"] COPY ["src/framework/Thor.LocalMemory.Cache/Thor.LocalMemory.Cache.csproj", "src/framework/Thor.LocalMemory.Cache/"] COPY ["src/framework/Thor.RabbitMQEvent/Thor.RabbitMQEvent.csproj", "src/framework/Thor.RabbitMQEvent/"] +COPY ["src/framework/Thor.Stack.Rabbit/Thor.Rabbit.csproj", "src/framework/Thor.Stack.Rabbit/"] COPY ["src/framework/Thor.RedisMemory.Cache/Thor.RedisMemory.Cache.csproj", "src/framework/Thor.RedisMemory.Cache/"] -COPY ["src/Thor.ServiceDefaults/Thor.ServiceDefaults.csproj", "src/Thor.ServiceDefaults/"] -COPY ["src/Provider/Thor.Provider.Sqlite/Thor.Provider.Sqlite.csproj", "src/Provider/Thor.Provider.Sqlite/"] -COPY ["src/Provider/Thor.Provider.PostgreSQL/Thor.Provider.PostgreSQL.csproj", "src/Provider/Thor.Provider.PostgreSQL/"] +COPY ["src/Provider/Thor.Provider.DM/Thor.Provider.DM.csproj", "src/Provider/Thor.Provider.DM/"] +COPY ["src/Thor.Core/Thor.Core.csproj", "src/Thor.Core/"] +COPY ["src/Thor.Domain/Thor.Domain.csproj", "src/Thor.Domain/"] +COPY ["src/Thor.Infrastructure/Thor.Infrastructure.csproj", "src/Thor.Infrastructure/"] COPY ["src/Provider/Thor.Provider.MySql/Thor.Provider.MySql.csproj", "src/Provider/Thor.Provider.MySql/"] +COPY ["src/Provider/Thor.Provider.PostgreSQL/Thor.Provider.PostgreSQL.csproj", "src/Provider/Thor.Provider.PostgreSQL/"] +COPY ["src/Provider/Thor.Provider.Sqlite/Thor.Provider.Sqlite.csproj", "src/Provider/Thor.Provider.Sqlite/"] COPY ["src/Provider/Thor.Provider.SqlServer/Thor.Provider.SqlServer.csproj", "src/Provider/Thor.Provider.SqlServer/"] -RUN dotnet restore "src/Thor.Service/Thor.Service.csproj" +COPY ["src/Thor.ServiceDefaults/Thor.ServiceDefaults.csproj", "src/Thor.ServiceDefaults/"] +RUN dotnet restore "./src/Thor.Service/Thor.Service.csproj" COPY . . WORKDIR "/src/src/Thor.Service" -RUN dotnet build "Thor.Service.csproj" -c $BUILD_CONFIGURATION -o /app/build +RUN dotnet build "./Thor.Service.csproj" -c $BUILD_CONFIGURATION -o /app/build +# 此阶段用于发布要复制到最终阶段的服务项目 FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "Thor.Service.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "./Thor.Service.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值) FROM base AS final WORKDIR /app COPY --from=publish /app/publish . COPY --from=lobe /src/dist ./wwwroot -ENTRYPOINT ["dotnet", "Thor.Service.dll"] +ENTRYPOINT ["dotnet", "Thor.Service.dll"] \ No newline at end of file diff --git a/src/Thor.Service/Properties/launchSettings.json b/src/Thor.Service/Properties/launchSettings.json index 20a4bf5..8127823 100644 --- a/src/Thor.Service/Properties/launchSettings.json +++ b/src/Thor.Service/Properties/launchSettings.json @@ -42,6 +42,16 @@ "OTEL_SERVICE_NAME": "Thor.Service" }, "distributionName": "" + }, + "Container (.NET SDK)": { + "commandName": "SdkContainer", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "environmentVariables": { + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": false } }, "$schema": "http://json.schemastore.org/launchsettings.json", diff --git a/src/Thor.Service/Thor.Service.csproj b/src/Thor.Service/Thor.Service.csproj index 6330fdc..aeb44cc 100644 --- a/src/Thor.Service/Thor.Service.csproj +++ b/src/Thor.Service/Thor.Service.csproj @@ -6,6 +6,9 @@ enable Linux ..\.. + linux-x64 + True + mcr.microsoft.com/dotnet/aspnet:9.0 @@ -65,10 +68,4 @@ - - - .dockerignore - - -