From 18e4088774033ce1da80839d057409813d798bc2 Mon Sep 17 00:00:00 2001
From: liuyg <liuyg@qq.com>
Date: Wed, 16 Mar 2022 16:25:55 +0800
Subject: [PATCH] 冲突
---
Jenkinsfile | 82 +++++++++++++
Dockerfile | 2
deploy/deploy.yml | 61 ++++++++++
vue.config.js | 4
nginx.conf | 165 +++++++++++++++++++++++++++
5 files changed, 313 insertions(+), 1 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 41eee30..066ce2a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,4 +3,6 @@
#将dist目录内容复制到nginx容器html内部
COPY dist /usr/share/nginx/html/
+COPY nginx.conf /etc/nginx/nginx.conf
+
EXPOSE 80
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..8c6c089
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,82 @@
+pipeline {
+ agent {
+ node {
+ label 'nodejs'
+ }
+
+ }
+ stages {
+ stage('拉取代码') {
+ agent none
+ steps {
+ container('nodejs') {
+ git(url: 'http://192.168.0.105:10010/r/zhba_enterprises.git', credentialsId: 'gitblit', branch: 'master', changelog: true, poll: false)
+ sh 'ls -al'
+ }
+ }
+ }
+
+ stage('项目编译') {
+ agent none
+ steps {
+ container('nodejs') {
+ sh 'ls'
+ sh 'npm install -g cnpm --registry=https://registry.npm.taobao.org'
+ sh 'cnpm i --no-package-lock'
+ sh 'cnpm run build'
+ }
+
+ }
+ }
+
+ stage('构建镜像') {
+ agent none
+ steps {
+ container('nodejs') {
+ sh 'ls'
+ sh 'docker build -t zhba-vue:latest -f Dockerfile .'
+ }
+
+ }
+ }
+
+ stage('推送镜像') {
+ agent none
+ steps {
+ container('nodejs') {
+ withCredentials([usernamePassword(credentialsId : 'aliyun' ,passwordVariable : 'DOCKER_PWD_VAR' ,usernameVariable : 'DOCKER_USER_VAR' ,)]) {
+ sh 'echo "$DOCKER_PWD_VAR" | docker login $REGISTRY -u "$DOCKER_USER_VAR" --password-stdin'
+ sh 'docker tag zhba-vue:latest $REGISTRY/$DOCKERHUB_NAMESPACE/zhba-vue:SNAPSHOT-$BUILD_NUMBER'
+ sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/zhba-vue:SNAPSHOT-$BUILD_NUMBER'
+ }
+
+ }
+
+ }
+ }
+
+ stage('部署到dev环境') {
+ agent none
+ steps {
+ kubernetesDeploy(configs: 'deploy/**', enableConfigSubstitution: true, kubeconfigId: 'kube-zhba')
+ }
+ }
+
+ stage('发送确认邮件') {
+ agent none
+ steps {
+ mail(to: '17512080612@163.com', subject: 'yygh-admin构建结果', body: "构建成功了 $BUILD_NUMBER")
+ }
+ }
+
+ }
+ environment {
+ DOCKER_CREDENTIAL_ID = 'dockerhub-id'
+ GITHUB_CREDENTIAL_ID = 'github-id'
+ KUBECONFIG_CREDENTIAL_ID = 'kube-zhba'
+ REGISTRY = 'registry.cn-hangzhou.aliyuncs.com'
+ DOCKERHUB_NAMESPACE = 'arsn'
+ GITHUB_ACCOUNT = 'kubesphere'
+ APP_NAME = 'devops-java-sample'
+ }
+}
\ No newline at end of file
diff --git a/deploy/deploy.yml b/deploy/deploy.yml
new file mode 100644
index 0000000..ace3530
--- /dev/null
+++ b/deploy/deploy.yml
@@ -0,0 +1,61 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ labels:
+ app: zhba-vue
+ name: zhba-vue
+ namespace: zhba #一定要写名称空间
+spec:
+ progressDeadlineSeconds: 600
+ replicas: 1
+ selector:
+ matchLabels:
+ app: zhba-vue
+ strategy:
+ rollingUpdate:
+ maxSurge: 50%
+ maxUnavailable: 50%
+ type: RollingUpdate
+ template:
+ metadata:
+ labels:
+ app: zhba-vue
+ spec:
+ imagePullSecrets:
+ - name: aliyun #提前在项目下配置访问阿里云的账号密码
+ containers:
+ # - image: $REGISTRY/$ALIYUNHUB_NAMESPACE/zhba-vue:SNAPSHOT-$BUILD_NUMBER
+ - image: registry.cn-hangzhou.aliyuncs.com/arsn/zhba-vue:SNAPSHOT-3
+ imagePullPolicy: Always
+ name: app
+ ports:
+ - containerPort: 80
+ protocol: TCP
+ resources:
+ limits:
+ cpu: 300m
+ memory: 600Mi
+ terminationMessagePath: /dev/termination-log
+ terminationMessagePolicy: File
+ dnsPolicy: ClusterFirst
+ restartPolicy: Always
+ terminationGracePeriodSeconds: 30
+---
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ app: zhba-vue
+ name: zhba-vue
+ namespace: zhba
+spec:
+ ports:
+ - name: http
+ port: 80
+ protocol: TCP
+ targetPort: 80
+ nodePort: 32248
+ selector:
+ app: zhba-vue
+ sessionAffinity: None
+ type: NodePort
\ No newline at end of file
diff --git a/nginx.conf b/nginx.conf
new file mode 100644
index 0000000..9dba282
--- /dev/null
+++ b/nginx.conf
@@ -0,0 +1,165 @@
+
+#user nobody;
+worker_processes 1;
+
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ #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 logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ server {
+ listen 80;
+ server_name localhost;
+ root /usr/share/nginx/html/;
+ index index.html index.htm;
+
+ location / {
+ #跨域设置
+ if ($request_method = 'OPTIONS') {
+ add_header 'Access-Control-Allow-Origin' '*';
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+
+ add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ add_header 'Access-Control-Allow-Headers' 'token,Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Data-Type,X-Requested-With,X-Data-Type,X-Auth-Token';
+ add_header 'Access-Control-Max-Age' 1728000;
+ add_header 'Content-Type' 'text/plain charset=UTF-8';
+ add_header 'Content-Length' 0;
+ return 204;
+ }
+ if ($request_method = 'POST') {
+ add_header 'Access-Control-Allow-Origin' '*';
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+ add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ }
+ if ($request_method = 'GET') {
+ add_header 'Access-Control-Allow-Origin' '*';
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
+ add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
+ }
+ }
+
+ location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
+ #允许跨域请求
+ add_header Access-Control-Allow-Origin '*';
+ add_header Access-Control-Allow-Headers X-Requested-With;
+ add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
+
+ expires 30d;
+ access_log off;
+ }
+
+
+
+
+ location ^~/api {
+ 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_buffering off;
+ client_max_body_size 100m;
+ rewrite ^/api/(.*)$ /$1 break;
+ proxy_pass http://zhbaw.zhba:81;
+ }
+
+
+ #charset koi8-r;
+
+ #access_log logs/host.access.log main;
+
+
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+ #
+ #location ~ \.php$ {
+ # proxy_pass http://127.0.0.1;
+ #}
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ #
+ #location ~ \.php$ {
+ # root html;
+ # fastcgi_pass 127.0.0.1:9000;
+ # fastcgi_index index.php;
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+ # include fastcgi_params;
+ #}
+
+ # deny access to .htaccess files, if Apache's document root
+ # concurs with nginx's one
+ #
+ #location ~ /\.ht {
+ # deny all;
+ #}
+ }
+
+
+ # another virtual host using mix of IP-, name-, and port-based configuration
+ #
+ #server {
+ # listen 8000;
+ # listen somename:8080;
+ # server_name somename alias another.alias;
+
+ # location / {
+ # root html;
+ # index index.html index.htm;
+ # }
+ #}
+
+
+ # HTTPS server
+ #
+ #server {
+ # listen 443 ssl;
+ # server_name localhost;
+
+ # ssl_certificate cert.pem;
+ # ssl_certificate_key cert.key;
+
+ # ssl_session_cache shared:SSL:1m;
+ # ssl_session_timeout 5m;
+
+ # ssl_ciphers HIGH:!aNULL:!MD5;
+ # ssl_prefer_server_ciphers on;
+
+ # location / {
+ # root html;
+ # index index.html index.htm;
+ # }
+ #}
+
+}
diff --git a/vue.config.js b/vue.config.js
index 10abcd2..e86a966 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -31,8 +31,10 @@
// 本地服务接口地址
// target: 'http://localhost:81',
// target: 'http://192.168.0.114:81', //钟日健W
- target: 'http://192.168.0.193:32248/api', //钟日健W备份
+ // target: 'http://192.168.0.193:32248/api', //钟日健W备份
// target: 'http://192.168.0.222:81', //自己W
+ target: 'http://zhbaw.zhba:81',
+ // target: 'http://192.168.0.114:81',//钟日健W
// target: 'http://localhost:81', //原W
// target: 'http://192.168.0.108:81',//原W
// target: 'http://192.168.0.107:81',//唐N
--
Gitblit v1.9.3