张 巡 1 год назад
Родитель
Сommit
7d6ba5b90b
4 измененных файлов с 232 добавлено и 1 удалено
  1. 4 1
      app/routers/auth.py
  2. 35 0
      condaenv.gakytdwy.requirements.txt
  3. 2 0
      deploy/Jenkinsfile
  4. 191 0
      deploy/idcprod/Jenkinsfile

+ 4 - 1
app/routers/auth.py

@@ -34,11 +34,14 @@ def switch_project(switch: schemas.SwitchProject):
         role_id = 4
     else:
         role_id = 5
+    jupyter_download = False
+    if super_admin_role in switch.role_ids:
+        jupyter_download = True
     token_data = {"user_id": switch.user_id, "user_name": switch.user_name,
                   "project_id": switch.project_id, "role_id": role_id}
     token_data_str = json.dumps(token_data)
     access_token = encode_base64(token_data_str).replace('\n', '')
-    return {"access_token": access_token, "token_type": "Bearer", "role_id": role_id}
+    return {"access_token": access_token, "token_type": "Bearer", "role_id": role_id, "jupyter_download": jupyter_download}
 
 
 @router.post("/login", response_model=schemas.Token)

+ 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

+ 2 - 0
deploy/Jenkinsfile

@@ -17,6 +17,7 @@ pipeline {
           echo "构建 Docker 镜像阶段"
           sh 'echo "nameserver 114.114.114.114" >> /etc/resolv.conf'
           sh 'docker build --target image-idctest  -t ${IMAGE_REPO}/aihub-backend:${ENV_APP} --output type=docker .'
+          sh 'docker build --target image-idcprod -t ${IMAGE_REPO}/datax-admin:${ENV_APP} --output type=docker .'
           echo "build success"
         }
         script {
@@ -30,6 +31,7 @@ pipeline {
           echo "Push Docker 镜像阶段"
           sh'docker images'
           sh 'docker push ${IMAGE_REPO}/aihub-backend:${ENV_APP} '
+          sh 'docker push ${IMAGE_REPO}/datax-admin:${ENV_APP} '
           echo "Push image success"
         }
         script {

+ 191 - 0
deploy/idcprod/Jenkinsfile

@@ -0,0 +1,191 @@
+def label = "slave-${UUID.randomUUID().toString()}"
+
+
+podTemplate(cloud: 'kubernetes', namespace:'devops',label: label, serviceAccount: 'jenkins',containers: [
+  containerTemplate(name: 'docker', image: 'docker:latest', command: 'cat', ttyEnabled: true),
+  containerTemplate(name: 'kubectl', image: 'cnych/kubectl', command: 'cat', ttyEnabled: true)
+],volumes: [
+  hostPathVolume(mountPath: '/home/jenkins/.kube', hostPath: '/root/.kube'),
+  hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
+  hostPathVolume(mountPath: '/etc/docker/daemon.json', hostPath: '/etc/docker/daemon.json'),
+  hostPathVolume(mountPath: '/root/.docker/config.json', hostPath: '/root/.docker/config.json')
+], yaml: """
+spec:
+  nodeSelector:
+    kubernetes.io/hostname: 10.138.130.97
+  tolerations:
+  - key: "node-role.kubernetes.io/master"
+    operator: "Equal"
+    value: "true"
+    effect: "NoSchedule"
+"""
+) {
+
+    node(label) {
+        stage('构建 Docker 镜像') {
+          // checkout([$class: 'GitSCM',
+          //         branches: [[name: '*/integration']],
+          //         userRemoteConfigs: [[credentialsId: '775e81f5-3243-4e23-9d1f-01b7e62597d4', url: 'http://10.138.130.21:8001/ai_repos/aihub-backend.git']]])
+          //         sleep 30
+          // }
+          git url: 'http://10.138.130.21:8001/aihub/aihub-backend-new.git', branch: 'integration'
+          container('docker') {
+            echo "构建 Docker 镜像阶段"
+            sh "echo 'nameserver 114.114.114.114' >> /etc/resolv.conf"
+            retry(2) { sh "docker build --target image-idcprod -t registry.cn-hangzhou.aliyuncs.com/sxtest/datax-admin:idcprod --output type=docker ." }
+            echo "build success"
+          }
+        }
+        stage('Docker Push 镜像') {
+            container('docker') {
+              retry(2) { sh "docker push registry.cn-hangzhou.aliyuncs.com/sxtest/datax-admin:idcprod" }
+              echo "Push success"
+            }
+        }
+        stage('运行 Kubectl') {
+          container('kubectl') {
+            echo "重启 pod"
+            sh "kubectl rollout restart deployments/aihub-dag-backend  -n ns-aihub-dag"
+          }
+        }
+    }
+}
+
+
+//
+// pipeline {
+//     agent { label 'jnlp-slave'}
+//
+//     options {
+//         buildDiscarder(logRotator(numToKeepStr: '10'))
+//         disableConcurrentBuilds()
+//         timeout(time: 20, unit: 'MINUTES')
+//         gitLabConnection('gitlab')
+//     }
+//
+//     environment {
+//         IMAGE_REPO = "112.29.146.236:5000/demo/myblog"
+//         DINGTALK_CREDS = credentials('dingTalk')
+//         TAB_STR = "\n                    \n                    "
+//     }
+//
+//     stages {
+//         stage('git-log') {
+//             steps {
+//                 script{
+//                     sh "git log --oneline -n 1 > gitlog.file"
+//                     env.GIT_LOG = readFile("gitlog.file").trim()
+//                 }
+//                 sh 'printenv'
+//             }
+//         }
+//         stage('checkout') {
+//             steps {
+//                 container('tools') {
+//                     checkout scm
+//                 }
+//                 updateGitlabCommitStatus(name: env.STAGE_NAME, state: 'success')
+//                 script{
+//                     env.BUILD_TASKS = env.STAGE_NAME + "√..." + env.TAB_STR
+//                 }
+//             }
+//         }
+//         stage('CI'){
+//             failFast true
+//             parallel {
+//                 stage('Unit Test') {
+//                     steps {
+//                         echo "Unit Test Stage Skip..."
+//                     }
+//                 }
+//                 stage('Code Scan') {
+//                     steps {
+//                         container('tools') {
+//                             withSonarQubeEnv('sonarqube') {
+//                                 sh 'sonar-scanner -X'
+//                                 sleep 3
+//                             }
+//                             script {
+//                                 timeout(1) {
+//                                     def qg = waitForQualityGate('sonarqube')
+//                                     if (qg.status != 'OK') {
+//                                         error "未通过Sonarqube的代码质量阈检查,请及时修改!failure: ${qg.status}"
+//                                     }
+//                                 }
+//                             }
+//                         }
+//                     }
+//                 }
+//             }
+//         }
+//         stage('build-image') {
+//             steps {
+//                 container('tools') {
+//                     retry(2) { sh 'docker build . -t ${IMAGE_REPO}:${GIT_COMMIT}'}
+//                 }
+//                 updateGitlabCommitStatus(name: env.STAGE_NAME, state: 'success')
+//                 script{
+//                     env.BUILD_TASKS += env.STAGE_NAME + "√..." + env.TAB_STR
+//                 }
+//             }
+//         }
+//         stage('push-image') {
+//             steps {
+//                 container('tools') {
+//                     retry(2) { sh 'docker push ${IMAGE_REPO}:${GIT_COMMIT}'}
+//                 }
+//                 updateGitlabCommitStatus(name: env.STAGE_NAME, state: 'success')
+//                 script{
+//                     env.BUILD_TASKS += env.STAGE_NAME + "√..." + env.TAB_STR
+//                 }
+//             }
+//         }
+//         stage('deploy') {
+//             steps {
+//                 container('tools') {
+//                     sh "sed -i 's#{{IMAGE_URL}}#${IMAGE_REPO}:${GIT_COMMIT}#g' deploy/*"
+//                     timeout(time: 1, unit: 'MINUTES') {
+//                         sh "kubectl apply -f deploy/"
+//                     }
+//                 }
+//                 updateGitlabCommitStatus(name: env.STAGE_NAME, state: 'success')
+//                 script{
+//                     env.BUILD_TASKS += env.STAGE_NAME + "√..." + env.TAB_STR
+//                 }
+//             }
+//         }
+//     }
+//     post {
+//         success {
+//             echo 'Congratulations!'
+//             sh """
+//                 curl 'https://oapi.dingtalk.com/robot/send?access_token=${DINGTALK_CREDS_PSW}' \
+//                     -H 'Content-Type: application/json' \
+//                     -d '{
+//                         "msgtype": "markdown",
+//                         "markdown": {
+//                             "title":"myblog",
+//                             "text": "😄👍 构建成功 👍😄  \n**项目名称**:jairmir  \n**Git log**: ${GIT_LOG}   \n**构建分支**: ${BRANCH_NAME}   \n**构建地址**:${RUN_DISPLAY_URL}  \n**构建任务**:${BUILD_TASKS}"
+//                         }
+//                     }'
+//             """
+//         }
+//         failure {
+//             echo 'Oh no!'
+//             sh """
+//                 curl 'https://oapi.dingtalk.com/robot/send?access_token=${DINGTALK_CREDS_PSW}' \
+//                     -H 'Content-Type: application/json' \
+//                     -d '{
+//                         "msgtype": "markdown",
+//                         "markdown": {
+//                             "title":"myblog",
+//                             "text": "😖❌ 构建失败 ❌😖  \n**项目名称**:jairmir  \n**Git log**: ${GIT_LOG}   \n**构建分支**: ${BRANCH_NAME}  \n**构建地址**:${RUN_DISPLAY_URL}  \n**构建任务**:${BUILD_TASKS}"
+//                         }
+//                     }'
+//             """
+//         }
+//         always {
+//             echo 'I will always say Hello again!'
+//         }
+//     }
+// }