From 2cd8b73aa3d25ea50d12cf4a52462cdc5c62b8d0 Mon Sep 17 00:00:00 2001 From: "fengxian.guo" Date: Sat, 21 Dec 2024 08:37:10 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20docker=20=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3=EF=BC=8C?= =?UTF-8?q?=E5=8F=8Adocker=E6=9E=84=E5=BB=BA=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Abp.Net8/src/Yi.Abp.Web/Dockerfile | 2 ++ .../src/Yi.Abp.Web/README-DOCKER-BUILD.md | 22 +++++++++++++++++++ Yi.Abp.Net8/src/Yi.Abp.Web/Yi.Abp.Web.csproj | 4 ++++ 3 files changed, 28 insertions(+) create mode 100644 Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/Dockerfile b/Yi.Abp.Net8/src/Yi.Abp.Web/Dockerfile index 91301637..21592fb0 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/Dockerfile +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/Dockerfile @@ -8,6 +8,8 @@ EXPOSE 8080 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src + +COPY ./common.props ./ COPY ["src/Yi.Abp.Web/Yi.Abp.Web.csproj", "src/Yi.Abp.Web/"] COPY ["framework/Yi.Framework.AspNetCore.Authentication.OAuth/Yi.Framework.AspNetCore.Authentication.OAuth.csproj", "framework/Yi.Framework.AspNetCore.Authentication.OAuth/"] COPY ["framework/Yi.Framework.AspNetCore/Yi.Framework.AspNetCore.csproj", "framework/Yi.Framework.AspNetCore/"] diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md b/Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md new file mode 100644 index 00000000..aba1e37f --- /dev/null +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md @@ -0,0 +1,22 @@ +# Docker 构建说明 + +## 执行命令 + +```shell +# 在Yi.Abp.Net8 目录下执行 +docker build -t xxx-xxx:${BUILD_NUMBER} -f ./src/Yi.Abp.Web/Dockerfile . + +``` + +## 注意 + +NuGet 源国内访问有时候会报错,可以考虑切换成华为源,加上参数 + +```shell +RUN dotnet restore --source https://repo.huaweicloud.com/repository/nuget/v3/index.json "./src/Yi.Abp.Web/./Yi.Abp.Web.csproj" + +RUN dotnet build --source https://repo.huaweicloud.com/repository/nuget/v3/index.json "./Yi.Abp.Web.csproj" -c $BUILD_CONFIGURATION -o /app/build + +RUN dotnet publish --source https://repo.huaweicloud.com/repository/nuget/v3/index.json "./Yi.Abp.Web.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false + +``` \ No newline at end of file diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/Yi.Abp.Web.csproj b/Yi.Abp.Net8/src/Yi.Abp.Web/Yi.Abp.Web.csproj index 2623b61f..5be942ee 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/Yi.Abp.Web.csproj +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/Yi.Abp.Web.csproj @@ -10,6 +10,10 @@ + + + + From fe97ba1c19abc5f2d7b604d716d173b47f7db932 Mon Sep 17 00:00:00 2001 From: "fengxian.guo" Date: Sat, 21 Dec 2024 08:57:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20docker=20=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3=EF=BC=8C?= =?UTF-8?q?=E5=8F=8Adocker=E6=9E=84=E5=BB=BA=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Yi.Abp.Web/README-DOCKER-BUILD.md | 2 +- Yi.RuoYi.Vue3/Dockerfile | 19 ++++++ Yi.RuoYi.Vue3/README-DOCKER-BUILD.md | 13 +++++ Yi.RuoYi.Vue3/nginx.conf | 58 +++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 Yi.RuoYi.Vue3/Dockerfile create mode 100644 Yi.RuoYi.Vue3/README-DOCKER-BUILD.md create mode 100644 Yi.RuoYi.Vue3/nginx.conf diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md b/Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md index aba1e37f..5589c57c 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/README-DOCKER-BUILD.md @@ -4,7 +4,7 @@ ```shell # 在Yi.Abp.Net8 目录下执行 -docker build -t xxx-xxx:${BUILD_NUMBER} -f ./src/Yi.Abp.Web/Dockerfile . +docker build -t admin-server:${BUILD_NUMBER} -f ./src/Yi.Abp.Web/Dockerfile . ``` diff --git a/Yi.RuoYi.Vue3/Dockerfile b/Yi.RuoYi.Vue3/Dockerfile new file mode 100644 index 00000000..e2e186bb --- /dev/null +++ b/Yi.RuoYi.Vue3/Dockerfile @@ -0,0 +1,19 @@ +FROM node:18-alpine AS build + +WORKDIR /app + +COPY package.json yarn.lock ./ + +RUN yarn cache clean +RUN rm -rf node_modules +RUN yarn install --registry=https://registry.npmmirror.com + +COPY . . + +# RUN node --max-old-space-size=4096 +RUN yarn build:prod + +FROM nginx:alpine +COPY nginx.conf /etc/nginx/nginx.conf +COPY --from=build /app/dist /usr/share/nginx/html +CMD ["nginx", "-g", "daemon off;"] diff --git a/Yi.RuoYi.Vue3/README-DOCKER-BUILD.md b/Yi.RuoYi.Vue3/README-DOCKER-BUILD.md new file mode 100644 index 00000000..63246145 --- /dev/null +++ b/Yi.RuoYi.Vue3/README-DOCKER-BUILD.md @@ -0,0 +1,13 @@ +# Docker 构建说明 + +## 执行命令 + +```shell +# 在Yi.RuoYi.Vue3 目录下执行 +docker build -t rouoyi-web:${BUILD_NUMBER} . + +``` + +## 注意 + +nginx.conf 中替换为自己服务器后端地址 \ No newline at end of file diff --git a/Yi.RuoYi.Vue3/nginx.conf b/Yi.RuoYi.Vue3/nginx.conf new file mode 100644 index 00000000..8ddec0d3 --- /dev/null +++ b/Yi.RuoYi.Vue3/nginx.conf @@ -0,0 +1,58 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + server { + listen 80; + + server_name _; + + root /usr/share/nginx/html; + index index.html index.htm; + + location /prod-api/ { + # 替换成自己的后端服务地址 + proxy_pass http://localhost:19001/api/app/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Authorization $http_authorization; + proxy_set_header Cookie $http_cookie; + } + + location /prod-ws/ { + # 替换成自己的后端服务地址 + proxy_pass http://localhost:19001/hub/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + # rewrite ^/prod-ws(/.*)$ $1 break; + } + + location / { + try_files $uri $uri/ /index.html; + } + + + error_page 404 /404.html; + location = /404.html { + root /usr/share/nginx/html; + } + + location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { + expires 1y; + add_header Cache-Control "public, no-transform"; + } + } +} From ea134f52be5de634fe420f665fe840521343dda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E7=BA=A7CV=E5=B7=A5=E7=A8=8B=E5=B8=88?= <2535688890@qq.com> Date: Sat, 21 Dec 2024 03:33:37 +0000 Subject: [PATCH 3/3] =?UTF-8?q?options=20=E6=8B=BC=E5=86=99=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 高级CV工程师 <2535688890@qq.com> --- Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index bcf35ec9..d148f226 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -1,4 +1,4 @@ -using System.Globalization; +using System.Globalization; using System.Text; using System.Text.Json.Serialization; using System.Text.Json.Serialization.Metadata; @@ -97,10 +97,10 @@ namespace Yi.Abp.Web var service = context.Services; //请求日志 - Configure(optios => + Configure(options => { //默认关闭,开启会有大量的审计日志 - optios.IsEnabled = true; + options.IsEnabled = true; }); //忽略审计日志路径 Configure(options =>