# DEploy feature branch stages: - test - test_build_static - build_docker_images - deploy variables: CONTAINER_IMAGE: $GITLAB_REGISTRY_URL/$GITLAB_REGISTRY_NAMESPACE/ensembl-client:${CI_COMMIT_SHORT_SHA} CONTAINER_INTERNAL_IMAGE: $GITLAB_REGISTRY_URL/$GITLAB_REGISTRY_NAMESPACE/ensembl-client:${CI_COMMIT_SHORT_SHA}-internal KUBECONFIG: /etc/deploy/config KUBECONTEXT: ens-dev-ctx DEPLOYENV: dev ENVIRONMENT: production DOCKER_TLS_CERTDIR: "" Test: image: node:10.16.0 stage: test before_script: - cd src/ensembl - npm ci script: - npm run check-types - npm run test except: - dev - master - /^feature\/.*$/ Test_N_Build: image: node:10.16.0 stage: test_build_static before_script: - cd src/ensembl - npm ci script: - npm run test - export NODE_ENV=production - export GOOGLE_ANALYTICS_KEY=${GA_KEY} - export ENVIRONMENT=production - export API_HOST="" - npm run build artifacts: name: static_assets paths: - src/ensembl/dist/ only: - dev - master Test_N_Build:internal: image: node:10.16.0 stage: test_build_static before_script: - cd src/ensembl - npm ci script: - npm run test - export NODE_ENV=development - export GOOGLE_ANALYTICS_KEY=${GA_KEY} - export ENVIRONMENT=internal - export API_HOST="" - npm run build artifacts: name: static_assets_internal paths: - src/ensembl/dist/ only: - master Test_N_Build:feature: image: node:10.16.0 stage: test_build_static before_script: - cd src/ensembl - npm ci script: - npm run test - export NODE_ENV=development - export GOOGLE_ANALYTICS_KEY=${GA_KEY} - export ENVIRONMENT=development - export API_HOST="" - npm run build artifacts: name: static_assets_feature paths: - src/ensembl/dist/ only: - /^feature\/.*$/ Nginx: image: docker services: - docker:dind stage: build_docker_images before_script: - case "${CI_COMMIT_REF_NAME}" in dev) DEPLOYENV="staging" ;; master) DEPLOYENV="prod" ;; cicd-test) DEPLOYENV="staging" ;; *) DEPLOYENV="dev" ;; esac script: - apk update && apk add git - git clone --depth 1 https://github.com/Ensembl/ensembl-2020-static-assests.git - git clone https://gitlab.ebi.ac.uk/kamal/ensembl-client-nginx.git - cd ensembl-client-nginx - git checkout june-release - cd .. - sed -i "s//${DEPLOYENV}/g" ensembl-client-nginx/config/conf.d/local.conf - docker build -t ${CONTAINER_IMAGE}-${DEPLOYENV} -f ensembl-client-nginx/Dockerfile --no-cache . - echo "$GITLAB_REGISTRY_TOKEN" | docker login -u "$GITLAB_REGISTRY_USER" --password-stdin https://"$GITLAB_REGISTRY_URL" - docker push ${CONTAINER_IMAGE}-${DEPLOYENV} - docker rmi ${CONTAINER_IMAGE}-${DEPLOYENV} - docker logout "$GITLAB_REGISTRY_URL" only: - dev - master dependencies: - Test_N_Build Nginx:internal: image: docker services: - docker:dind stage: build_docker_images before_script: - case "${CI_COMMIT_REF_NAME}" in dev) DEPLOYENV="staging" ;; master) DEPLOYENV="prod" ;; cicd-test) DEPLOYENV="staging" ;; *) DEPLOYENV="dev" ;; esac script: - apk update && apk add git - git clone --depth 1 https://github.com/Ensembl/ensembl-2020-static-assests.git - git clone https://gitlab.ebi.ac.uk/kamal/ensembl-client-nginx.git - cd ensembl-client-nginx - git checkout june-release - cd .. - sed -i "s//internal/g" ensembl-client-nginx/config/conf.d/local.conf - cat ensembl-client-nginx/config/conf.d/local.conf - docker build -t ${CONTAINER_INTERNAL_IMAGE} -f ensembl-client-nginx/Dockerfile --no-cache . - echo "$GITLAB_REGISTRY_TOKEN" | docker login -u "$GITLAB_REGISTRY_USER" --password-stdin https://"$GITLAB_REGISTRY_URL" - docker push ${CONTAINER_IMAGE}-internal - docker rmi ${CONTAINER_IMAGE}-internal - docker logout "$GITLAB_REGISTRY_URL" only: - master dependencies: - Test_N_Build:internal Nginx:feature: image: docker services: - docker:dind stage: build_docker_images before_script: - case "${CI_COMMIT_REF_NAME}" in dev) DEPLOYENV="staging" ;; master) DEPLOYENV="prod" ;; cicd-test) DEPLOYENV="staging" ;; *) DEPLOYENV="dev" ;; esac script: - feature_branch=${CI_COMMIT_REF_NAME} - feature_tag=${feature_branch#"feature/"} - apk update && apk add git - git clone --depth 1 https://github.com/Ensembl/ensembl-2020-static-assests.git - git clone https://gitlab.ebi.ac.uk/kamal/ensembl-client-nginx.git - cd ensembl-client-nginx - git checkout june-release - cd .. - sed -i "s//internal/g" ensembl-client-nginx/config/conf.d/local.conf - cat ensembl-client-nginx/config/conf.d/local.conf - docker build -t ${CONTAINER_IMAGE}-$feature_tag -f ensembl-client-nginx/Dockerfile --no-cache . - echo "$GITLAB_REGISTRY_TOKEN" | docker login -u "$GITLAB_REGISTRY_USER" --password-stdin https://"$GITLAB_REGISTRY_URL" - docker push ${CONTAINER_IMAGE}-$feature_tag - docker rmi ${CONTAINER_IMAGE}-$feature_tag - docker logout "$GITLAB_REGISTRY_URL" only: - /^feature\/.*$/ dependencies: - Test_N_Build:feature Staging: stage: deploy image: alpine before_script: - mkdir -p /etc/deploy - echo ${EMBASSY_KUBECONFIG} | base64 -d > ${KUBECONFIG} script: - apk update && apk add --no-cache curl git - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl - chmod +x ./kubectl - mv ./kubectl /usr/local/bin/kubectl - git clone https://gitlab.ebi.ac.uk/kamal/ensembl-client-caas-deploy.git - cd ensembl-client-caas-deploy - git checkout refactor-manifest - cd .. - sed -i "s//${CI_COMMIT_SHORT_SHA}-staging/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - sed -i "s//staging/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - cat ensembl-client-caas-deploy/ensembl_client_deployment.yaml - kubectl config view - kubectl config use-context ens-stage-ctx - kubectl apply -f ensembl-client-caas-deploy/ensembl_client_deployment.yaml only: - dev dependencies: - Nginx Live: stage: deploy image: alpine before_script: - mkdir -p /etc/deploy - echo ${EMBASSY_KUBECONFIG} | base64 -d > ${KUBECONFIG} script: - apk update && apk add --no-cache curl git - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl - chmod +x ./kubectl - mv ./kubectl /usr/local/bin/kubectl - git clone https://gitlab.ebi.ac.uk/kamal/ensembl-client-caas-deploy.git - cd ensembl-client-caas-deploy - git checkout refactor-manifest - cd .. - sed -i "s//${CI_COMMIT_SHORT_SHA}-prod/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - sed -i "s//prod/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - cat ensembl-client-caas-deploy/ensembl_client_deployment.yaml - kubectl config view - kubectl config use-context ens-prod-ctx - kubectl apply -f ensembl-client-caas-deploy/ensembl_client_deployment.yaml only: - master dependencies: - Nginx Deploy:internal: stage: deploy image: alpine before_script: - mkdir -p /etc/deploy - echo ${EMBASSY_KUBECONFIG} | base64 -d > ${KUBECONFIG} script: - apk update && apk add --no-cache curl git - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl - chmod +x ./kubectl - mv ./kubectl /usr/local/bin/kubectl - git clone https://gitlab.ebi.ac.uk/kamal/ensembl-client-caas-deploy.git - cd ensembl-client-caas-deploy - git checkout refactor-manifest - cd .. - sed -i "s//${CI_COMMIT_SHORT_SHA}-internal/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - sed -i "s//internal/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - cat ensembl-client-caas-deploy/ensembl_client_deployment.yaml - kubectl config view - kubectl config use-context ens-dev-ctx - kubectl apply -f ensembl-client-caas-deploy/ensembl_client_deployment.yaml only: - master dependencies: - Nginx:internal Deploy:feature: stage: deploy image: alpine before_script: - mkdir -p /etc/deploy - echo ${EMBASSY_KUBECONFIG} | base64 -d > ${KUBECONFIG} script: - feature_branch=${CI_COMMIT_REF_NAME} - feature_tag=${feature_branch#"feature/"} - apk update && apk add --no-cache curl git - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl - chmod +x ./kubectl - mv ./kubectl /usr/local/bin/kubectl - git clone https://gitlab.ebi.ac.uk/kamal/ensembl-client-caas-deploy.git - cd ensembl-client-caas-deploy - git checkout refactor-manifest - cd .. - sed -i "s//${CI_COMMIT_SHORT_SHA}-$feature_tag/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - sed -i "s//$feature_tag/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml - cat ensembl-client-caas-deploy/ensembl_client_deployment.yaml - kubectl config view - kubectl config use-context ens-dev-ctx - kubectl apply -f ensembl-client-caas-deploy/ensembl_client_deployment.yaml only: - /^feature\/.*$/ dependencies: - Nginx:feature