张 巡 1 jaar geleden
bovenliggende
commit
cc4cd266d8
3 gewijzigde bestanden met toevoegingen van 130 en 0 verwijderingen
  1. 35 0
      condaenv.gakytdwy.requirements.txt
  2. 52 0
      deploy/Jenkinsfile
  3. 43 0
      deploy/KubernetesPod.yaml

+ 35 - 0
condaenv.gakytdwy.requirements.txt

@@ -0,0 +1,35 @@
+cmake
+opencv-python
+cython
+fastapi
+uvicorn
+pytest
+jinja2
+aiofiles
+python-multipart
+requests
+gunicorn
+fastapi-pagination==0.9.3
+pymysql==1.0.2
+pylint==2.5.3
+sqlfluff==1.3.1
+PyHive==0.6.5
+pure-sasl==0.6.2
+thrift==0.16.0
+thrift-sasl==0.4.3
+mysql-connector==2.2.9
+mysql-connector-python==8.0.29
+SQLAlchemy==1.4.9
+numpy
+pandas
+minio==5.0.1
+Pillow==9.1.1
+croniter==1.3.7
+uvloop
+kubernetes
+httptools
+apscheduler
+werkzeug==0.16.0
+itsdangerous==1.1.0
+kazoo==2.9.0
+-i https://mirror.baidu.com/pypi/simple

+ 52 - 0
deploy/Jenkinsfile

@@ -0,0 +1,52 @@
+pipeline {
+  agent {
+    kubernetes {
+      yamlFile 'deploy/KubernetesPod.yaml'
+      retries 2
+    }
+  }
+  environment {
+    IMAGE_REPO = "registry.cn-hangzhou.aliyuncs.com/sxtest"
+    TAB = "\n   \n  "
+    BUILD_TASKS = "\n   \n  "
+  }
+  stages{
+    stage('构建镜像') {
+      steps {
+        container('docker') {
+          echo "构建 Docker 镜像阶段"
+          sh 'echo "nameserver 114.114.114.114" >> /etc/resolv.conf'
+          sh 'docker build --target image-idcprod -t ${IMAGE_REPO}/aihub-backend:sxtest --output type=docker .'
+          echo "build success"
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+      }
+    }
+    stage('镜像推送') {
+      steps {
+        container('docker') {
+          echo "Push Docker 镜像阶段"
+          sh'docker images'
+          sh 'docker push ${IMAGE_REPO}/aihub-backend:sxtest '
+          echo "Push image success"
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+      }
+    }
+    stage('重启服务') {
+      steps {
+        container('kubectl') {
+          sh 'kubectl version'
+        }
+        script {
+          env.BUILD_TASKS += env.STAGE_NAME + "✅" + env.TAB
+        }
+        sh 'printenv'
+      }
+    }
+  }
+    }

+ 43 - 0
deploy/KubernetesPod.yaml

@@ -0,0 +1,43 @@
+apiVersion: v1
+kind: Pod
+metadata:
+  labels:
+    aihub-backend: aihub-backend
+spec:
+  containers:
+  - name: docker
+    image: docker:latest
+    imagePullPolicy: IfNotPresent
+    command:
+    - cat
+    tty: true
+    volumeMounts:
+    - mountPath: "/etc/docker/daemon.json"
+      name: "volume-docker1"
+    - mountPath: "/root/.docker/config.json"
+      name: "docker-auth"
+    - mountPath: "/var/run/docker.sock"
+      name: "volume-docker0"
+  - name: kubectl
+    image: cnych/kubectl
+    imagePullPolicy: IfNotPresent
+    command:
+    - cat
+    tty: true
+  volumes:
+   - name: volume-docker0
+     hostPath:
+       path: "/var/run/docker.sock"
+   - name: docker-auth
+     hostPath:
+       path: "/root/.docker/config.json"
+   - name: volume-docker1
+     hostPath:
+       path: "/etc/docker/daemon.json"
+  nodeSelector:
+    kubernetes.io/hostname: 10.138.130.97
+  tolerations:
+    - key: "node-role.kubernetes.io/master"
+      operator: "Equal"
+      value: "true"
+      effect: "NoSchedule"