From 0ffee518dc1276d55e18cecb318d60d69d5dc2bb Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 26 Mar 2026 22:06:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eatyou=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.prod-atyou | 19 ++++++++++++ Dockerfile-atu | 6 ++++ nginx/default-atu.conf | 34 ++++++++++++++++++++++ package.json | 1 + pipeline-atyou | 66 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 .env.prod-atyou create mode 100644 Dockerfile-atu create mode 100644 nginx/default-atu.conf create mode 100644 pipeline-atyou diff --git a/.env.prod-atyou b/.env.prod-atyou new file mode 100644 index 0000000..9f7c1b2 --- /dev/null +++ b/.env.prod-atyou @@ -0,0 +1,19 @@ +ENV = 'development' + +VUE_APP_BASE_API = '/console' + +VUE_CLI_BABEL_TRANSPILE_MODULES = true + +# application base url +VUE_APP_BASE_URL ='https://console.atuchat.com/api' + +# oss +VUE_APP_OSS_BUCKET = 'tkm-likei' +VUE_APP_OSS_URL = 'https://tkm-likei.oss-ap-southeast-1.aliyuncs.com' + +# h5 +VUE_APP_H5_BASE_URL = 'https://h5.likeichat.com' + +# start mock +VUE_APP_START_MOCK = false + diff --git a/Dockerfile-atu b/Dockerfile-atu new file mode 100644 index 0000000..20796e4 --- /dev/null +++ b/Dockerfile-atu @@ -0,0 +1,6 @@ +FROM registry.cn-hangzhou.aliyuncs.com/public_mirror_images/nginx:1.26.2 +COPY dist/ /usr/share/nginx/html/ +COPY nginx/nginx.conf /etc/nginx/nginx.conf +COPY nginx/default-atu.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 + diff --git a/nginx/default-atu.conf b/nginx/default-atu.conf new file mode 100644 index 0000000..8cce033 --- /dev/null +++ b/nginx/default-atu.conf @@ -0,0 +1,34 @@ +server { + listen 80; + listen [::]:80; + server_name _; + root /usr/share/nginx/html; + + # Load configuration files for the default server block. + include /etc/nginx/default.d/*.conf; + location / { + # 此处的 @router 实际上是引用下面的转发,否则在 Vue 路由刷新时可能会抛出 404 + try_files $uri $uri/ @router; + # 请求指向的首页 + index index.html; + } + location /console { + proxy_pass http://console.prod.svc.cluster.local/console; + 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_connect_timeout 30s; + proxy_read_timeout 60s; + proxy_send_timeout 30s; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + } + error_page 404 /404.html; + location = /404.html { + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + } +} diff --git a/package.json b/package.json index 459ec17..21474be 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dev": "vue-cli-service serve", "build:dev": "vue-cli-service build --mode development", "build:prod": "vue-cli-service build", + "build:atu-prod": "vue-cli-service build --mode prod-atyou", "build:stage": "vue-cli-service build --mode staging", "preview": "node build/index.js --preview", "lint": "eslint --ext .js,.vue src", diff --git a/pipeline-atyou b/pipeline-atyou new file mode 100644 index 0000000..ff8c75b --- /dev/null +++ b/pipeline-atyou @@ -0,0 +1,66 @@ +pipeline { + + agent { + label "dev" + } + + tools { + nodejs 'node14' + } + + environment { + PATH = "/var/jenkins_home/docker-cli/bin:/var/jenkins_home/kubectl/bin:${env.PATH}" + BUILD_IMAGE = "${sh(script:'echo -n likei-dev:page-console-$(date +%Y%m%dv%H%M%S)', returnStdout: true)}" + ALIYUN_REGISTRY = "tuokemi-con-registry.ap-southeast-1.cr.aliyuncs.com/atyou-prod/page-console" + IMAGE_REP_TAG = "" + K8S_NAMESPACE = "prod" + K8S_DEPLOYMENT = "console-page" + K8S_APP_LABEL = "console-page" + DOCKER_FILE = "Dockerfile-atu" + } + + stages { + stage('Build') { + steps { + sh 'export PATH=$HOME/bin:$PATH && export NODE_HOME=/usr/local/node && export PATH=$NODE_HOME/bin:$PATH && npm config set registry https://registry.npmmirror.com && npm install' + sh 'export PATH=$HOME/bin:$PATH && export NODE_HOME=/usr/local/node && export PATH=$NODE_HOME/bin:$PATH && npm run build:atu-prod' + sh 'du -sh dist' + script { + IMAGE_REP_TAG = "${ALIYUN_REGISTRY}:page-console-${sh(script:'date +%Y%m%dv%H%M%S', returnStdout: true).trim()}" + } + echo "---> Image registry tag: ${IMAGE_REP_TAG}" + } + } + stage('Build image') { + steps { + withCredentials([usernamePassword( + credentialsId: 'aliyun-registry', + usernameVariable: 'ALIYUN_USER', + passwordVariable: 'ALIYUN_PASS' + )]) { + sh 'echo $ALIYUN_PASS | docker login --username $ALIYUN_USER --password-stdin tuokemi-con-registry.ap-southeast-1.cr.aliyuncs.com' + } + sh "docker build -f ${DOCKER_FILE} -t ${IMAGE_REP_TAG} ." + } + } + stage('Upload image') { + steps { + sh "docker push ${IMAGE_REP_TAG}" + sh "docker tag ${IMAGE_REP_TAG} ${ALIYUN_REGISTRY}:latest" + sh "docker push ${ALIYUN_REGISTRY}:latest" + sh "docker rmi -f ${IMAGE_REP_TAG} ${ALIYUN_REGISTRY}:latest" + } + } + stage('Apply') { + steps { + sh "kubectl -n ${K8S_NAMESPACE} set image deployment/${K8S_DEPLOYMENT} ${K8S_APP_LABEL}=${IMAGE_REP_TAG.replace('tuokemi-con-registry', 'tuokemi-con-registry-vpc')}" + } + } + } + + post { + always { + cleanWs() + } + } +}