2 Commits 3e9b4d33e9 ... 7065d3ca0e

Author SHA1 Message Date
  mayan31370 7065d3ca0e Merge branch 'master' of git.mayan31370.space:aibaidu/aisite 2 years ago
  mayan31370 78cf6be9f3 添加部署脚本 2 years ago
3 changed files with 90 additions and 0 deletions
  1. 5 0
      Dockerfile
  2. 57 0
      Jenkinsfile
  3. 28 0
      nginx.conf

+ 5 - 0
Dockerfile

@@ -0,0 +1,5 @@
+FROM nginx:latest
+
+ADD dist/ /usr/share/nginx/html
+
+ADD nginx.conf /etc/nginx/nginx.conf

+ 57 - 0
Jenkinsfile

@@ -0,0 +1,57 @@
+pipeline {
+  agent any
+  options {
+    skipDefaultCheckout true
+  }
+  stages {
+    stage('checkout') {
+      steps {
+        checkout scm
+      }
+    }
+    stage('npm install') {
+      steps {
+        script {
+          sh "cnpm install"
+        }
+      }
+    }
+    stage('npm build') {
+      steps {
+        script {
+          sh "cnpm run build"
+        }
+      }
+    }
+    stage('build docker image') {
+      steps {
+        script {
+          sh "aws ecr get-login-password --region cn-north-1 | docker login --username AWS --password-stdin 226381024927.dkr.ecr.cn-north-1.amazonaws.com.cn"
+          sh "docker build -t aibaidu/h5 ."
+        }
+      }
+    }
+    stage('push docker image') {
+      steps {
+        script {
+          sh "docker tag aibaidu/h5:latest 226381024927.dkr.ecr.cn-north-1.amazonaws.com.cn/aibaidu/h5:latest"
+          sh "docker push 226381024927.dkr.ecr.cn-north-1.amazonaws.com.cn/aibaidu/h5:latest"
+        }
+      }
+    }
+    stage('deploy') {
+      steps {
+        script {
+          sh "ssh -o StrictHostKeyChecking=no aibaidu-admin './deploy-h5.sh'"
+        }
+      }
+    }
+    stage('Send notify'){
+      steps{
+        script{
+          sh "curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=743fe5f4-d4cf-4906-8aa5-93353a4287da' -H 'Content-Type: application/json' -d '{\"msgtype\": \"text\",\"text\": {\"content\": \"AI-Site部署完成\",\"mentioned_list\":[\"yaoxin\",\"TianShanFeiMao\"]}}'"
+        }
+      }
+    }
+  }
+}

+ 28 - 0
nginx.conf

@@ -0,0 +1,28 @@
+worker_processes  auto;
+worker_cpu_affinity auto;
+
+events {
+    worker_connections  8096;
+}
+
+http {
+
+	include       mime.types;
+    default_type  application/octet-stream;
+
+
+    server {
+        listen  80;
+        charset utf-8;
+        server_name_in_redirect off;
+        gzip on;
+        gzip_buffers 4 16k;
+        gzip_comp_level 6;
+        gzip_vary on;
+        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
+        location / {
+            try_files $uri $uri/ /index.html;
+            root   /usr/share/nginx/html;
+        }
+    }
+}