From 1ba897422205ea763178c343dc886075aaedc5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=85=86=E9=91=AB?= Date: Tue, 23 Sep 2025 18:29:10 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=96=B0=E5=A2=9Edocker=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 30 ++++++++++++++++++ applications/KonSoft.AuthServer/Dockerfile | 24 ++++++++++++++ .../KonSoft.AuthServer.csproj | 3 ++ .../Properties/launchSettings.json | 31 +++++++++++++------ .../KonSoft.Admin.HttpApi.Host/Dockerfile | 30 ++++++++++++++++++ .../KonSoft.Admin.HttpApi.Host.csproj | 3 ++ .../Properties/launchSettings.json | 31 +++++++++++++------ 7 files changed, 132 insertions(+), 20 deletions(-) create mode 100644 .dockerignore create mode 100644 applications/KonSoft.AuthServer/Dockerfile create mode 100644 microservices/KonSoft.Admin.HttpApi.Host/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fe1152b --- /dev/null +++ b/.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/applications/KonSoft.AuthServer/Dockerfile b/applications/KonSoft.AuthServer/Dockerfile new file mode 100644 index 0000000..260756b --- /dev/null +++ b/applications/KonSoft.AuthServer/Dockerfile @@ -0,0 +1,24 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["NuGet.Config", "."] +COPY ["applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj", "applications/KonSoft.AuthServer/"] +RUN dotnet restore "./applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj" +COPY . . +WORKDIR "/src/applications/KonSoft.AuthServer" +RUN dotnet build "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./KonSoft.AuthServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "KonSoft.AuthServer.dll"] \ No newline at end of file diff --git a/applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj b/applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj index f91a8e1..8481f66 100644 --- a/applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj +++ b/applications/KonSoft.AuthServer/KonSoft.AuthServer.csproj @@ -11,6 +11,8 @@ false true KonSoft-4681b4fd-151f-4221-84a4-929d86723e4c + Linux + ..\.. @@ -37,6 +39,7 @@ + diff --git a/applications/KonSoft.AuthServer/Properties/launchSettings.json b/applications/KonSoft.AuthServer/Properties/launchSettings.json index 67f6051..ba47da3 100644 --- a/applications/KonSoft.AuthServer/Properties/launchSettings.json +++ b/applications/KonSoft.AuthServer/Properties/launchSettings.json @@ -1,12 +1,4 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "https://localhost:44322", - "sslPort": 44322 - } - }, "profiles": { "IIS Express": { "commandName": "IISExpress", @@ -18,10 +10,29 @@ "KonSoft.AuthServer": { "commandName": "Project", "launchBrowser": true, - "applicationUrl": "https://localhost:44322", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "applicationUrl": "https://localhost:44322" + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "https://localhost:44322", + "sslPort": 44322 } } } \ No newline at end of file diff --git a/microservices/KonSoft.Admin.HttpApi.Host/Dockerfile b/microservices/KonSoft.Admin.HttpApi.Host/Dockerfile new file mode 100644 index 0000000..9284b90 --- /dev/null +++ b/microservices/KonSoft.Admin.HttpApi.Host/Dockerfile @@ -0,0 +1,30 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER $APP_UID +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["NuGet.Config", "."] +COPY ["microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj", "microservices/KonSoft.Admin.HttpApi.Host/"] +COPY ["modules/admin/src/KonSoft.Admin.Application/KonSoft.Admin.Application.csproj", "modules/admin/src/KonSoft.Admin.Application/"] +COPY ["modules/admin/src/KonSoft.Admin.Domain/KonSoft.Admin.Domain.csproj", "modules/admin/src/KonSoft.Admin.Domain/"] +COPY ["modules/admin/src/KonSoft.Admin.Domain.Shared/KonSoft.Admin.Domain.Shared.csproj", "modules/admin/src/KonSoft.Admin.Domain.Shared/"] +COPY ["modules/admin/src/KonSoft.Admin.Application.Contracts/KonSoft.Admin.Application.Contracts.csproj", "modules/admin/src/KonSoft.Admin.Application.Contracts/"] +COPY ["modules/admin/src/KonSoft.Admin.EntityFrameworkCore/KonSoft.Admin.EntityFrameworkCore.csproj", "modules/admin/src/KonSoft.Admin.EntityFrameworkCore/"] +COPY ["modules/admin/src/KonSoft.Admin.HttpApi/KonSoft.Admin.HttpApi.csproj", "modules/admin/src/KonSoft.Admin.HttpApi/"] +RUN dotnet restore "./microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj" +COPY . . +WORKDIR "/src/microservices/KonSoft.Admin.HttpApi.Host" +RUN dotnet build "./KonSoft.Admin.HttpApi.Host.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./KonSoft.Admin.HttpApi.Host.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "KonSoft.Admin.HttpApi.Host.dll"] \ No newline at end of file diff --git a/microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj b/microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj index 810219e..3bac00b 100644 --- a/microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj +++ b/microservices/KonSoft.Admin.HttpApi.Host/KonSoft.Admin.HttpApi.Host.csproj @@ -6,9 +6,12 @@ KonSoft.Admin true KonSoft.Admin-4681b4fd-151f-4221-84a4-929d86723e4c + Linux + ..\.. + diff --git a/microservices/KonSoft.Admin.HttpApi.Host/Properties/launchSettings.json b/microservices/KonSoft.Admin.HttpApi.Host/Properties/launchSettings.json index 6beb1ca..67003eb 100644 --- a/microservices/KonSoft.Admin.HttpApi.Host/Properties/launchSettings.json +++ b/microservices/KonSoft.Admin.HttpApi.Host/Properties/launchSettings.json @@ -1,12 +1,4 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "https://localhost:44354", - "sslPort": 44354 - } - }, "profiles": { "IIS Express": { "commandName": "IISExpress", @@ -18,10 +10,29 @@ "KonSoft.Admin.HttpApi.Host": { "commandName": "Project", "launchBrowser": true, - "applicationUrl": "https://localhost:44354", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "applicationUrl": "https://localhost:44354" + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true + } + }, + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "https://localhost:44354", + "sslPort": 44354 } } } \ No newline at end of file