feat:新增测试环境docker部署

This commit is contained in:
liulong 2026-05-24 14:16:34 +08:00
parent 6f174c20e7
commit 0ebca75894
7 changed files with 256 additions and 6 deletions

View File

@ -37,6 +37,7 @@ bash build.sh 1.0.0-BETA
3. 构建后端统一镜像 `txw-all`
4. 构建前端镜像 `txw-web`
#### 构建测试环境
仅构建后端
```
@ -46,10 +47,10 @@ docker build -t txw-all:1.0.0-BETA -t txw-all:latest -f devops/Dockerfile .
仅构建前端
```
docker build -t txw-web:1.0.0-BETA -t txw-web:latest -f devops/web/Dockerfile .
docker build -t txw-web:1.0.0-BETA -t txw-web:latest -f devops/web/Dockerfile.test .
```
构建arm64架构
#### 构建arm64架构 生产环境
构建前端

View File

@ -6,7 +6,10 @@ set -e
# 用法: bash devops/pack-image.sh <txw-web|txw-all> [VERSION] [SERVER_USER] [SERVER_HOST]
# 示例:
# bash ./devops/pack-image.sh txw-web 1.0.0 root 192.168.1.100
# ./devops/pack-image.sh txw-all 1.0.0
# ./devops/pack-image.sh txw-all 1.0.0 这是后端正式环境打包
# ./devops/pack-image.sh txw-all 1.0.0-BETA 这是后端测试环境打包
# ./devops/pack-image.sh txw-web 1.0.0 这是前端正式环境打包
# ./devops/pack-image.sh txw-web 1.0.0-BETA 这是前端测试环境打包
# bash devops/pack-image.sh txw-all
# ============================================================

View File

@ -0,0 +1,24 @@
## ============================================================
## 碳信网 - 前端镜像
## 前提:本地先执行 npm run build 构建前端
## 构建:
## cd txw-mhzc-web && npm install && npm run build
## cd txw-yygl-web && npm install && npm run build
## ============================================================
FROM nginx:alpine
# 复制 nginx 配置
COPY devops/web/nginx.test.conf /etc/nginx/nginx.conf
COPY devops/web/default.json /etc/nginx/oem/default.json
COPY devops/web/baidu_verify_codeva-5rH3psCeMQ.html /etc/nginx/verify/baidu_verify_codeva-5rH3psCeMQ.html
COPY devops/web/proxy-common.conf /etc/nginx/proxy-common.conf
# 复制预构建的前端产物
COPY txw-mhzc-web/dist /usr/share/nginx/html/txw-mhzc-web
COPY txw-yygl-web/dist /usr/share/nginx/html/txw-yygl-web
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

221
devops/web/nginx.test.conf Normal file
View File

@ -0,0 +1,221 @@
worker_processes auto;
worker_rlimit_nofile 65535;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 8192;
use epoll;
multi_accept on;
}
http {
# 日志格式
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# 基础配置
client_max_body_size 100m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Gzip 压缩http 级别)
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/x-javascript
text/xml application/xml application/xml+rss
application/javascript text/javascript
application/vnd.ms-fontobject application/x-font-ttf
font/opentype image/svg+xml image/x-icon;
# 代理超时配置
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
send_timeout 300s;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# =============================================
# HTTPS Server 块
# =============================================
# =============================================
# 主 Server 块(保留非 HTTPS 请求处理)
# =============================================
server {
listen 80 default_server;
absolute_redirect off;
server_name _;
# Gzip 压缩server 级别,微调)
gzip_min_length 1024;
gzip_types text/plain text/css application/json application/javascript
application/x-javascript text/xml application/xml
application/xml+rss text/javascript image/svg+xml;
if ($request_method = OPTIONS) {
return 403;
}
# 健康检查
location /healthcheck {
access_log off;
return 200 'OK';
add_header Content-Type text/plain;
}
# Ping 接口
location /ping {
return 200 "ok";
}
# API 代理(网关)
location ~ ^/(mhzc|gxzx|sso|yygl) {
include proxy-common.conf;
proxy_pass http://txw-gateway:9300;
}
location ~ ^/nacos(/.*)$ {
include proxy-common.conf;
proxy_pass http://txw-nacos:8080$1;
}
location ^~ /admin/ {
proxy_pass http://172.21.79.119:18777/;
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 Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache off;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 600s;
}
location ^~ /web/ {
proxy_pass http://172.21.79.119:18778/;
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 Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache off;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 600s;
}
location ^~ /h5/ {
proxy_pass http://172.21.79.119:18779/;
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 Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache off;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 600s;
}
# 百度验证
location = /baidu_verify_codeva-5rH3psCeMQ.html {
alias /etc/nginx/verify/baidu_verify_codeva-5rH3psCeMQ.html;
}
location = /baidu_verify_codeva-eE1giHswVL.html {
return 200 "2c7cc0bcf0ecd060ab8f7fe919acc078";
add_header Content-Type text/html;
}
# --------------------------------------------------------
# 运营支撑前端mhzc
# --------------------------------------------------------
location /view/mhzc {
return 301 /view/mhzc/;
}
location /view/mhzc/ {
alias /usr/share/nginx/html/txw-mhzc-web/;
# 静态资源90天缓存
location ~* \.(gif|jpg|jpeg|png|css|js|ico|eot|svg|ttf|woff|woff2)$ {
expires 90d;
add_header Cache-Control "public";
try_files $uri =404;
}
# 非静态资源1小时缓存
expires 1h;
add_header Cache-Control "public";
try_files $uri $uri/ /view/mhzc/index.html;
}
# --------------------------------------------------------
# 运营管理前端yygl
# --------------------------------------------------------
location /view/yygl {
return 301 /view/yygl/;
}
location /view/yygl/ {
alias /usr/share/nginx/html/txw-yygl-web/;
# 静态资源90天缓存
location ~* \.(gif|jpg|jpeg|png|css|js|ico|eot|svg|ttf|woff|woff2)$ {
expires 90d;
add_header Cache-Control "public";
try_files $uri =404;
}
# 非静态资源1小时缓存
expires 1h;
add_header Cache-Control "public";
try_files $uri $uri/ /view/yygl/index.html;
}
# --------------------------------------------------------
# 默认首页重定向
# --------------------------------------------------------
location / {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires 0;
return 301 /view/mhzc/;
}
# 错误页面
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# 引入其他 location 配置
include ./location.d/*.conf;
}

View File

@ -104,5 +104,6 @@
"main": "index.js",
"repository": "http://10.23.12.27:8089/qyd-znsb/znsb-mhzc.git",
"author": "wangjianxin@css.com.cn <wangjianxin@css.com.cn>",
"license": "MIT"
"license": "MIT",
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
}

View File

@ -24,7 +24,7 @@
<div class="top-hero-head">
<h1 class="top-title-text">可信碳信息网</h1>
<p class="top-title-desc">
让中国的每一碳都拥有独一无二的可信数字身份
让中国的每一碳都拥有独一无二的可信数字身份
</p>
</div>

View File

@ -103,7 +103,7 @@ export default {
left: 0;
z-index: 0;
width: 100%;
height: calc(@hyzt-landing-bg-height / @hyzt-landing-bg-design-width * 100vw);
height: (@hyzt-landing-bg-height / @hyzt-landing-bg-design-width) * 100vw;
min-height: @hyzt-landing-bg-height;
pointer-events: none;
background: url(../../assets/hyzt/banner-bg.png) no-repeat center top;