feat: 正式环境构建
This commit is contained in:
parent
01e92a5be0
commit
e016eb7e11
@ -1,10 +1,16 @@
|
||||
# ============================================================
|
||||
# 碳信网 - 统一后端构建镜像
|
||||
# 支持多平台构建: docker buildx build --platform linux/arm64,linux/amd64
|
||||
# 使用方式: docker run -e SERVICE_NAME=gateway txw-all:latest
|
||||
# ============================================================
|
||||
|
||||
# Stage 1: Build
|
||||
FROM maven:3.6.3-openjdk-8 AS builder
|
||||
# 使用多架构 Maven 镜像,自动选择对应平台版本
|
||||
FROM --platform=$BUILDPLATFORM maven:3.6.3-openjdk-8 AS builder
|
||||
|
||||
# Maven 构建参数
|
||||
ARG TARGETARCH
|
||||
ARG BUILDARCH
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
@ -47,6 +53,8 @@ COPY txw-yygl/txw-yygl-service-biz/src yygl/txw-yygl-service-biz/src
|
||||
|
||||
# -------------------------------------------
|
||||
# Step 2: 复制 Maven 本地仓库(离线构建)
|
||||
# 注意:若本地仓库中有编译好的二进制 native 库(非 Java byte code),
|
||||
# 需要确保这些库是跨平台的,或在 ARM64 上重新构建
|
||||
# -------------------------------------------
|
||||
COPY script/.m2/repository /root/.m2/repository
|
||||
|
||||
@ -83,17 +91,23 @@ WORKDIR /build/gateway
|
||||
RUN mvn clean package -DskipTests -s settings.xml -o || mvn clean package -DskipTests
|
||||
|
||||
# Stage 2: Package
|
||||
FROM eclipse-temurin:8-jre
|
||||
# 使用多架构 JRE 镜像,指定目标平台
|
||||
FROM --platform=$TARGETARCH eclipse-temurin:8-jre
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 安装字体(用于验证码 Captcha)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
fonts-noto-cjk \
|
||||
# 使用中科大镜像加速
|
||||
RUN echo 'deb http://mirrors.ustc.edu.cn/ubuntu-ports/ noble main restricted universe multiverse' > /etc/apt/sources.list && \
|
||||
echo 'deb http://mirrors.ustc.edu.cn/ubuntu-ports/ noble-updates main restricted universe multiverse' >> /etc/apt/sources.list && \
|
||||
echo 'deb http://mirrors.ustc.edu.cn/ubuntu-ports/ noble-backports main restricted universe multiverse' >> /etc/apt/sources.list && \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
fontconfig \
|
||||
fonts-noto-cjk \
|
||||
&& fc-cache -f -v \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY devops/start.sh /app/start.sh
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
|
||||
@ -43,13 +43,26 @@ bash build.sh 1.0.0-BETA
|
||||
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 .
|
||||
```
|
||||
|
||||
构建arm64架构
|
||||
|
||||
构建前端
|
||||
|
||||
```bash
|
||||
docker buildx build --platform linux/arm64 -t txw-web:1.0.0 -f devops/web/Dockerfile . --load
|
||||
```
|
||||
|
||||
构建后端
|
||||
|
||||
```bash
|
||||
docker buildx build --platform linux/arm64 -t txw-all:1.0.0 -f devops/Dockerfile . --load
|
||||
```
|
||||
|
||||
### 更新镜像
|
||||
|
||||
代码变更后,重新构建并启动:
|
||||
|
||||
107
devops/docker-compose.infra.prod.yml
Normal file
107
devops/docker-compose.infra.prod.yml
Normal file
@ -0,0 +1,107 @@
|
||||
version: '3.8'
|
||||
|
||||
# ============================================================
|
||||
# 碳信网 - 基础设施服务
|
||||
# 使用方式:
|
||||
# 启动基础设施: docker-compose up -d
|
||||
# ============================================================
|
||||
|
||||
services:
|
||||
|
||||
nacos:
|
||||
image: nacos/nacos-server:v3.0.2
|
||||
container_name: txw-nacos
|
||||
expose:
|
||||
- "8848"
|
||||
- "9848"
|
||||
- "9849"
|
||||
environment:
|
||||
- MODE=standalone
|
||||
- PREFER_HOST_MODE=hostname
|
||||
- JVM_XMS=512m
|
||||
- JVM_XMX=512m
|
||||
- JVM_XMN=256m
|
||||
- NACOS_AUTH_ENABLE=true
|
||||
- NACOS_AUTH_IDENTITY_KEY=1qazXSW@3edcVFR$
|
||||
- NACOS_AUTH_IDENTITY_VALUE=7ygvBHU*9ijnMKO)
|
||||
- NACOS_AUTH_TOKEN=TmFjb3NBdXRoVG9rZW5TZWNyZXRLZXkyMDI0Rm9yRGV2RW52aXJvbm1lbnQ=
|
||||
- NACOS_CORE_AUTH_SERVER_IDENTITY_KEY=nacos
|
||||
- NACOS_CORE_AUTH_SERVER_IDENTITY_VALUE=nacos2024
|
||||
volumes:
|
||||
- ./nacos/data:/home/nacos/data
|
||||
- ./nacos/logs:/home/nacos/logs
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8848/nacos"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
container_name: txw-redis
|
||||
expose:
|
||||
- "6379"
|
||||
command: redis-server --ignore-warnings ARM64-COW-BUG --requirepass redis_password
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
minio:
|
||||
image: minio/minio:latest
|
||||
container_name: txw-minio
|
||||
expose:
|
||||
- "9000"
|
||||
- "9001"
|
||||
environment:
|
||||
- MINIO_ROOT_USER=minioadmin
|
||||
- MINIO_ROOT_PASSWORD=minioadmin123
|
||||
command: server /data --console-address ":9001"
|
||||
volumes:
|
||||
- ./minio-data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
mysql:
|
||||
image: biarms/mysql:5.7
|
||||
container_name: txw-mysql
|
||||
expose:
|
||||
- "3306"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=MysqlRootPwd@2024#Secure
|
||||
- MYSQL_DATABASE=txw_db
|
||||
volumes:
|
||||
- ./mysql-data:/var/lib/mysql
|
||||
- ./mysql-init:/docker-entrypoint-initdb.d
|
||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-pMysqlRootPwd@2024#Secure"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
networks:
|
||||
txw-network:
|
||||
name: txw-network
|
||||
driver: bridge
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
nacos-data:
|
||||
redis-data:
|
||||
minio-data:
|
||||
mysql-data:
|
||||
@ -9,7 +9,7 @@ version: '3.8'
|
||||
services:
|
||||
|
||||
nacos:
|
||||
image: nacos/nacos-server:v2.3.2
|
||||
image: nacos/nacos-server:v3.0.2
|
||||
container_name: txw-nacos
|
||||
ports:
|
||||
- "8848:8848"
|
||||
|
||||
@ -17,7 +17,7 @@ services:
|
||||
- SPRING_PROFILES_ACTIVE=prod
|
||||
- NACOS_SERVER_ADDR=nacos:8848
|
||||
ports:
|
||||
- "9300:9300"
|
||||
- ":9300"
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
@ -32,7 +32,7 @@ services:
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_REDIS_PASSWORD=redis_password
|
||||
ports:
|
||||
- "9301:9301"
|
||||
- ":9301"
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
@ -47,7 +47,7 @@ services:
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_REDIS_PASSWORD=redis_password
|
||||
ports:
|
||||
- "9302:9302"
|
||||
- ":9302"
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
@ -62,7 +62,7 @@ services:
|
||||
- SPRING_REDIS_PORT=6379
|
||||
- SPRING_REDIS_PASSWORD=redis_password
|
||||
ports:
|
||||
- "20010:20010"
|
||||
- ":20010"
|
||||
networks:
|
||||
- txw-network
|
||||
|
||||
|
||||
@ -10,14 +10,16 @@ version: '3.8'
|
||||
services:
|
||||
|
||||
web:
|
||||
image: txw-web:1.0.0-BETA
|
||||
image: txw-web:1.0.0
|
||||
container_name: txw-web
|
||||
environment:
|
||||
- SERVICE_NAME=gateway
|
||||
- SPRING_PROFILES_ACTIVE=test
|
||||
- NACOS_SERVER_ADDR=nacos:8848
|
||||
- NACOS_SERVER_ADDR=txw-nacos:8848
|
||||
ports:
|
||||
- "30090:80"
|
||||
volumes:
|
||||
- ./web/nginx.conf:/etc/nginx/nginx.conf
|
||||
deploy:
|
||||
replicas: 1
|
||||
resources:
|
||||
|
||||
@ -14,7 +14,7 @@ services:
|
||||
# ============================================
|
||||
|
||||
nacos:
|
||||
image: nacos/nacos-server:v2.3.2 # Nacos 官方镜像,指定稳定版本(避免latest)
|
||||
image: nacos/nacos-server:v3.0.2 # Nacos 官方镜像,指定稳定版本(避免latest)
|
||||
container_name: txw-nacos # 容器名称,方便管理
|
||||
ports:
|
||||
- "8848:8848" # Nacos 核心端口(Web控制台+API)
|
||||
|
||||
4
devops/mysql-init/init.sql
Normal file
4
devops/mysql-init/init.sql
Normal file
@ -0,0 +1,4 @@
|
||||
-- 创建 txw 用户并授权
|
||||
CREATE USER IF NOT EXISTS 'txw'@'%' IDENTIFIED BY 'txwKXTXXW123@!';
|
||||
GRANT ALL PRIVILEGES ON txw_db.* TO 'txw'@'%';
|
||||
FLUSH PRIVILEGES;
|
||||
@ -5,7 +5,7 @@ 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
|
||||
# bash ./devops/pack-image.sh txw-web 1.0.0 root 192.168.1.100
|
||||
# bash devops/pack-image.sh txw-all
|
||||
# ============================================================
|
||||
|
||||
|
||||
@ -81,6 +81,11 @@ http {
|
||||
proxy_pass http://txw-gateway:9300;
|
||||
}
|
||||
|
||||
# Nacos 代理
|
||||
location ~ ^/nacos(/.*)?$ {
|
||||
proxy_pass http://txw-nacos:8848$1;
|
||||
}
|
||||
|
||||
# 百度验证
|
||||
location = /baidu_verify_codeva-5rH3psCeMQ.html {
|
||||
alias /etc/nginx/verify/baidu_verify_codeva-5rH3psCeMQ.html;
|
||||
|
||||
@ -4,10 +4,10 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: txw-nacos:8848
|
||||
username: qyddev
|
||||
password: "9!1%Sw#QydNacosDev"
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
discovery:
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
metadata:
|
||||
version: 1.0.0-SNAPSHOT # 服务实例的版本号,可用于灰度发布
|
||||
|
||||
@ -19,9 +19,9 @@ spring:
|
||||
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
|
||||
config:
|
||||
server-addr: txw-nacos:8848 # Nacos 服务器地址(本地开发环境)
|
||||
username: qyddev
|
||||
password: "9!1%Sw#QydNacosDev"
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name
|
||||
file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties
|
||||
|
||||
@ -128,6 +128,7 @@ export default {
|
||||
name: 'tzzx',
|
||||
title: '碳证中心',
|
||||
iframeUrl: 'https://ctn-web-pre.lingshu.net/carbon-index',
|
||||
path:'/carbon-index',
|
||||
needLogin: true,
|
||||
clientId: 'client_id_tfwzx',//单点登录接入子系统的标识,由txw_sso_client表配置
|
||||
child: [
|
||||
@ -140,6 +141,7 @@ export default {
|
||||
needLogin: true, //是否需要登录才能访问
|
||||
clientId: 'client_id_tfwzx',
|
||||
iframeUrl: 'https://ctn-web-pre.lingshu.net/trustedCarbonQuery/index', //外部系统链接地址
|
||||
path: '/trustedCarbonQuery/index',
|
||||
// iframeUrl: 'https://ctn-web-pre.lingshu.net/trustedCarbonQuery/list?type=carbon-query', //外部系统链接地址
|
||||
},
|
||||
{
|
||||
@ -151,6 +153,7 @@ export default {
|
||||
needLogin: true,
|
||||
clientId: 'client_id_tfwzx',
|
||||
iframeUrl: 'https://ctn-web-pre.lingshu.net/carbon-protection',
|
||||
path: '/carbon-protection'
|
||||
},
|
||||
{
|
||||
name: 'tzhy',
|
||||
@ -161,6 +164,7 @@ export default {
|
||||
needLogin: true,
|
||||
clientId: 'client_id_tfwzx',
|
||||
iframeUrl: 'https://ctn-web-pre.lingshu.net/carbon-verify',
|
||||
path: '/carbon-verify'
|
||||
},
|
||||
{
|
||||
name: 'tgbcz',
|
||||
@ -171,6 +175,7 @@ export default {
|
||||
needLogin: true,
|
||||
clientId: 'client_id_tfwzx',
|
||||
iframeUrl: 'https://ctn-web-pre.lingshu.net/carbon-report-cert',
|
||||
path: '/carbon-report-cert'
|
||||
},
|
||||
{
|
||||
name: 'tbgtg',
|
||||
@ -181,6 +186,7 @@ export default {
|
||||
needLogin: true,
|
||||
clientId: 'client_id_tfwzx',
|
||||
iframeUrl: 'https://ctn-web-pre.lingshu.net/carbon-report-hosting',
|
||||
path: '/carbon-report-hosting'
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -246,7 +252,7 @@ export default {
|
||||
},
|
||||
|
||||
created() {
|
||||
// this.gettfwzxurl();
|
||||
this.gettfwzxurl();
|
||||
},
|
||||
mounted() {
|
||||
// this.gettfwzxurl();
|
||||
@ -387,11 +393,26 @@ export default {
|
||||
// const res = await getMxjbxx(prame);
|
||||
const { data } = await api.tfwzxurl();
|
||||
this.kxurl = data.kxtfwzx;
|
||||
|
||||
// 更新 menuOptions 中所有 iframe 菜单的 iframeUrl
|
||||
this.updateIframeUrl(this.menuOptions);
|
||||
|
||||
console.log('res', data);
|
||||
} catch (error) {
|
||||
console.error('数据加载失败', error);
|
||||
}
|
||||
},
|
||||
updateIframeUrl(menus) {
|
||||
if (!menus || !this.kxurl) return;
|
||||
menus.forEach(menu => {
|
||||
if (menu.path) {
|
||||
menu.iframeUrl = `${this.kxurl}${menu.path}`;
|
||||
}
|
||||
if (menu.child && menu.child.length > 0) {
|
||||
this.updateIframeUrl(menu.child);
|
||||
}
|
||||
});
|
||||
},
|
||||
gologin() {
|
||||
this.closeMobileMenu();
|
||||
this.$router.push("/login")
|
||||
|
||||
@ -4,10 +4,10 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: txw-nacos:8848
|
||||
username: qyddev
|
||||
password: "9!1%Sw#QydNacosDev"
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
discovery:
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
|
||||
--- #################### 配置中心相关配置 ####################
|
||||
|
||||
@ -17,9 +17,9 @@ spring:
|
||||
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
|
||||
config:
|
||||
server-addr: txw-nacos:8848 # Nacos 服务器地址(本地开发环境)
|
||||
username: qyddev
|
||||
password: "9!1%Sw#QydNacosDev"
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name
|
||||
file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties
|
||||
|
||||
@ -4,10 +4,10 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: txw-nacos:8848
|
||||
username: qyddev
|
||||
password: "9!1%Sw#QydNacosDev"
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
discovery:
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
metadata:
|
||||
version: 1.0.0-SNAPSHOT # 服务实例的版本号,可用于灰度发布
|
||||
|
||||
@ -19,9 +19,9 @@ spring:
|
||||
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
|
||||
config:
|
||||
server-addr: txw-nacos:8848 # Nacos 服务器地址(本地开发环境)
|
||||
username: qyddev
|
||||
password: "9!1%Sw#QydNacosDev"
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name
|
||||
file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties
|
||||
|
||||
@ -4,10 +4,10 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: txw-nacos:8848
|
||||
username: qyddev
|
||||
password: 9!1%Sw#QydNacosDev
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
discovery:
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
metadata:
|
||||
version: 1.0.0-SNAPSHOT # 服务实例的版本号,可用于灰度发布
|
||||
|
||||
@ -19,9 +19,9 @@ spring:
|
||||
# Nacos Config 配置项,对应 NacosConfigProperties 配置属性类
|
||||
config:
|
||||
server-addr: txw-nacos:8848 # Nacos 服务器地址(本地开发环境)
|
||||
username: qyddev
|
||||
password: 9!1%Sw#QydNacosDev
|
||||
namespace: bcf8de57-7215-4934-aced-ab382d504aff # 命名空间。这里使用本地开发环境
|
||||
username: nacos
|
||||
password: "nacos2024"
|
||||
namespace: 79f610cd-f637-4c0c-9faa-fd0ca688aa02 # 命名空间。这里使用本地开发环境
|
||||
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
|
||||
name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name
|
||||
file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties
|
||||
|
||||
Loading…
Reference in New Issue
Block a user