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 Test: image: node:10.16.0 stage: test before_script: - cd src/ensembl - npm ci script: - npm run test except: - dev - master 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 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} -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} - docker rmi ${CONTAINER_IMAGE} - 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} - docker rmi ${CONTAINER_IMAGE} - docker logout "$GITLAB_REGISTRY_URL" only: - master dependencies: - Test_N_Build:internal 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 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}/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}/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