|
| 1 | +image: docker:latest |
| 2 | +services: |
| 3 | + - docker:dind |
| 4 | + |
| 5 | +stages: |
| 6 | + - build-frontend |
| 7 | + - build-artefact |
| 8 | + - build-container |
| 9 | + - build-frontend-release |
| 10 | + - build-artefact-release |
| 11 | + - build-container-release |
| 12 | + - deploy-sandbox |
| 13 | + - deploy-fallback |
| 14 | + - deploy-live |
| 15 | + |
| 16 | +variables: |
| 17 | + DOCKER_DRIVER: overlay2 |
| 18 | + DOCKER_TLS_CERTDIR: "" |
| 19 | + REGISTRY_IMAGE: ebispot/ontotools-curation-service |
| 20 | + SERVICE_NAME: ontotools-curation-service |
| 21 | + |
| 22 | +build-front: |
| 23 | + image: node:10.15.3 |
| 24 | + stage: build-frontend |
| 25 | + script: |
| 26 | + - npm -v |
| 27 | + - node -v |
| 28 | + - cd frontend |
| 29 | + - rm -rf node_modules |
| 30 | + - npm install |
| 31 | + - CI=false npm run build:sandbox |
| 32 | + artifacts: |
| 33 | + paths: |
| 34 | + - frontend/build/* |
| 35 | + only: |
| 36 | + - develop |
| 37 | + |
| 38 | +maven-build: |
| 39 | + image: maven:3-jdk-12 |
| 40 | + stage: build-artefact |
| 41 | + script: |
| 42 | + - mkdir src/main/webapp |
| 43 | + - mv frontend/build/* src/main/webapp/ |
| 44 | + - ls -lah src/main/webapp |
| 45 | + - mvn clean package spring-boot:repackage -DskipTests=true |
| 46 | + dependencies: |
| 47 | + - build-front |
| 48 | + artifacts: |
| 49 | + paths: |
| 50 | + - target/*.war |
| 51 | + only: |
| 52 | + - develop |
| 53 | + |
| 54 | +build-container: |
| 55 | + stage: build-container |
| 56 | + script: |
| 57 | + - echo "$DOCKER_HUB_PASSWORD" > dhpw.txt |
| 58 | + - docker login -u "${DOCKER_HUB_USER}" --password-stdin < dhpw.txt |
| 59 | + - docker build --cache-from $REGISTRY_IMAGE:latest -t $REGISTRY_IMAGE:$CI_COMMIT_SHA . |
| 60 | + - docker push $REGISTRY_IMAGE:$CI_COMMIT_SHA |
| 61 | + only: |
| 62 | + - develop |
| 63 | + |
| 64 | +build-front-release: |
| 65 | + image: node:10.15.3 |
| 66 | + stage: build-frontend-release |
| 67 | + script: |
| 68 | + - npm -v |
| 69 | + - node -v |
| 70 | + - cd frontend |
| 71 | + - rm -rf node_modules |
| 72 | + - npm install |
| 73 | + - CI=false npm run build:prod |
| 74 | + artifacts: |
| 75 | + paths: |
| 76 | + - frontend/build/* |
| 77 | + only: |
| 78 | + - tags |
| 79 | + |
| 80 | +maven-build-release: |
| 81 | + image: maven:3-jdk-12 |
| 82 | + stage: build-artefact-release |
| 83 | + script: |
| 84 | + - mkdir src/main/webapp |
| 85 | + - mv frontend/build/* src/main/webapp/ |
| 86 | + - ls -lah src/main/webapp |
| 87 | + - mvn clean package spring-boot:repackage -DskipTests=true |
| 88 | + dependencies: |
| 89 | + - build-front-release |
| 90 | + artifacts: |
| 91 | + paths: |
| 92 | + - target/*.war |
| 93 | + only: |
| 94 | + - tags |
| 95 | + |
| 96 | +build-release: |
| 97 | + variables: |
| 98 | + GIT_STRATEGY: none |
| 99 | + stage: build-container-release |
| 100 | + script: |
| 101 | + - echo "$DOCKER_HUB_PASSWORD" > dhpw.txt |
| 102 | + - docker login -u "${DOCKER_HUB_USER}" --password-stdin < dhpw.txt |
| 103 | + - docker pull $REGISTRY_IMAGE:$CI_COMMIT_SHA |
| 104 | + - docker tag $REGISTRY_IMAGE:$CI_COMMIT_SHA $REGISTRY_IMAGE:latest |
| 105 | + - docker tag $REGISTRY_IMAGE:$CI_COMMIT_SHA $REGISTRY_IMAGE:$CI_COMMIT_TAG |
| 106 | + - docker push $REGISTRY_IMAGE:latest |
| 107 | + - docker push $REGISTRY_IMAGE:$CI_COMMIT_TAG |
| 108 | + only: |
| 109 | + - tags |
| 110 | + |
| 111 | +deploy-sandbox: |
| 112 | + image: dtzar/helm-kubectl:2.13.1 |
| 113 | + stage: deploy-sandbox |
| 114 | + script: |
| 115 | + - echo "Deploy to sandbox server" |
| 116 | + - mkdir -p /root/.kube |
| 117 | + - echo ${SANBOX_KUBECONF} | base64 -d > /root/.kube/config |
| 118 | + - helm init --stable-repo-url https://charts.helm.sh/stable |
| 119 | + - helm delete --purge ontotools-curation-service || true |
| 120 | + - helm install --name ontotools-curation-service --set k8Namespace=ontotools,image.repository=$REGISTRY_IMAGE,image.tag=$CI_COMMIT_SHA,image.env.secretsName=ontotools-secrets,image.env.secretsKey=db-pwd ./k8chart/ --wait |
| 121 | + environment: |
| 122 | + name: sandbox |
| 123 | + when: manual |
| 124 | + only: |
| 125 | + - develop |
| 126 | + |
| 127 | +deploy-fallback: |
| 128 | + image: dtzar/helm-kubectl:2.13.1 |
| 129 | + stage: deploy-fallback |
| 130 | + script: |
| 131 | + - echo "Deploy to Production fallback server" |
| 132 | + - mkdir -p /root/.kube |
| 133 | + - echo ${PFALLBACK_KUBECONFIG} | base64 -d > /root/.kube/config |
| 134 | + - helm init --stable-repo-url https://charts.helm.sh/stable |
| 135 | + - helm delete --purge ontotools-curation-service || true |
| 136 | + - helm install --name ontotools-curation-service --set k8Namespace=ontotools,replicaCount=1,image.env.envName=prod,image.repository=$REGISTRY_IMAGE,image.tag=$CI_COMMIT_SHA,image.env.dbUser=ontotoolscurator,image.env.secretsName=ontotools-secrets,image.env.secretsKey=db-pwd ./k8chart/ --wait |
| 137 | + environment: |
| 138 | + name: prod |
| 139 | + when: manual |
| 140 | + only: |
| 141 | + - tags |
| 142 | + |
| 143 | +deploy-live: |
| 144 | + image: dtzar/helm-kubectl:2.13.1 |
| 145 | + stage: deploy-live |
| 146 | + script: |
| 147 | + - echo "Deploy to Production server" |
| 148 | + - mkdir -p /root/.kube |
| 149 | + - echo ${PLIVE_KUBECONFIG} | base64 -d > /root/.kube/config |
| 150 | + - helm init --stable-repo-url https://charts.helm.sh/stable |
| 151 | + - helm delete --purge ontotools-curation-service || true |
| 152 | + - helm install --name ontotools-curation-service --set k8Namespace=ontotools,replicaCount=1,image.env.envName=prod,image.repository=$REGISTRY_IMAGE,image.tag=$CI_COMMIT_SHA,image.env.dbUser=ontotoolscurator,image.env.secretsName=ontotools-secrets,image.env.secretsKey=db-pwd ./k8chart/ --wait |
| 153 | + environment: |
| 154 | + name: prod |
| 155 | + when: manual |
| 156 | + only: |
| 157 | + - tags |
0 commit comments