From f761157a1c609c27e9908f5a5735acaa5c4d9793 Mon Sep 17 00:00:00 2001 From: zpc Date: Thu, 27 Mar 2025 23:33:42 +0800 Subject: [PATCH] 1 --- ShengShengBuXi/.dockerignore | 30 +++++++++ ShengShengBuXi/Dockerfile | 30 +++++++++ ShengShengBuXi/Properties/launchSettings.json | 67 +++++++++++-------- ShengShengBuXi/ShengShengBuXi.csproj | 11 +++ 4 files changed, 110 insertions(+), 28 deletions(-) create mode 100644 ShengShengBuXi/.dockerignore create mode 100644 ShengShengBuXi/Dockerfile diff --git a/ShengShengBuXi/.dockerignore b/ShengShengBuXi/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/ShengShengBuXi/.dockerignore @@ -0,0 +1,30 @@ +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/azds.yaml +**/bin +**/charts +**/docker-compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md +!**/.gitignore +!.git/HEAD +!.git/config +!.git/packed-refs +!.git/refs/heads/** \ No newline at end of file diff --git a/ShengShengBuXi/Dockerfile b/ShengShengBuXi/Dockerfile new file mode 100644 index 0000000..b7b9626 --- /dev/null +++ b/ShengShengBuXi/Dockerfile @@ -0,0 +1,30 @@ +# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。 + +# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时 +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 80 +EXPOSE 81 + + +# 此阶段用于生成服务项目 +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["ShengShengBuXi.csproj", "."] +RUN dotnet restore "./ShengShengBuXi.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "./ShengShengBuXi.csproj" -c $BUILD_CONFIGURATION -o /app/build + +# 此阶段用于发布要复制到最终阶段的服务项目 +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./ShengShengBuXi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值) +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "ShengShengBuXi.dll"] \ No newline at end of file diff --git a/ShengShengBuXi/Properties/launchSettings.json b/ShengShengBuXi/Properties/launchSettings.json index 5601c63..e3de4c0 100644 --- a/ShengShengBuXi/Properties/launchSettings.json +++ b/ShengShengBuXi/Properties/launchSettings.json @@ -1,4 +1,42 @@ { + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5140" + }, + "https": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7254;http://localhost:5140" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true + } + }, "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, @@ -7,32 +45,5 @@ "applicationUrl": "http://localhost:1623", "sslPort": 44359 } - }, - "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://localhost:5140", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "https": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "https://localhost:7254;http://localhost:5140", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } } -} +} \ No newline at end of file diff --git a/ShengShengBuXi/ShengShengBuXi.csproj b/ShengShengBuXi/ShengShengBuXi.csproj index e8b30cf..36a4256 100644 --- a/ShengShengBuXi/ShengShengBuXi.csproj +++ b/ShengShengBuXi/ShengShengBuXi.csproj @@ -4,8 +4,18 @@ net8.0 enable enable + b0658d0a-4c8d-42d5-beef-352248837997 + Linux + . + + + + + + + PreserveNewest @@ -14,6 +24,7 @@ +