.gitlab-ci.yml 3.69 KB
Newer Older
1
2
3
4
5
6
# CICD - Reload with /api/ensembl_object endpoint
stages:
  - test
  - test_build_static
  - build_docker_images
  - deploy
Andrey Azov's avatar
Andrey Azov committed
7

8
9
10
11
12
variables:
  CONTAINER_IMAGE: $GITLAB_REGISTRY_URL/$GITLAB_REGISTRY_NAMESPACE/ensembl-client:${CI_COMMIT_SHORT_SHA}
  KUBECONFIG: /etc/deploy/config
  KUBECONTEXT: ens-dev-ctx
  DEPLOYENV: dev
Andrey Azov's avatar
Andrey Azov committed
13

14
15
16
Test:
  image: node:10.15.1
  stage: test
Andrey Azov's avatar
Andrey Azov committed
17

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  before_script:
  - cd src/ensembl
  - npm ci

  script:
  - npm run test

  except:
  - dev
  - master

Test & Build:
  image: node:10.15.1
  stage: test_build_static

  before_script:
  - cd src/ensembl
  - npm ci

  script:
  - npm run test
  - export NODE_ENV=production
  - export API_HOST=''
  - npm run build

  artifacts:
    name: static_assets
    paths:
    - src/ensembl/dist/

  only:
  - dev
  - 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" ;; *) DEPLOYENV="dev" ;; esac

  script:
  - apk update && apk add git
  - git clone --depth 1 https://github.com/Ensembl/ensembl-2020-static-assests.git
  - git clone --depth 1 https://gitlab.ebi.ac.uk/kamal/ensembl-client-nginx.git
  - cd ensembl-client-nginx
  - git checkout june-release
  - cd ..
  - sed -i "s/<DEPLOYMNET_ENV>/${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

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/<VERSION>/${CI_COMMIT_SHORT_SHA}/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml
  - sed -i "s/<DEPLOYMNET_ENV>/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

Live:
  stage: deploy
  image: alpine
  before_script:
  - mkdir -p /etc/deploy
  - echo ${EMBASSY_KUBECONFIG} | base64 -d > ${KUBECONFIG}
Andrey Azov's avatar
Andrey Azov committed
111
  script:
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  - 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/<VERSION>/${CI_COMMIT_SHORT_SHA}/g" ensembl-client-caas-deploy/ensembl_client_deployment.yaml
  - sed -i "s/<DEPLOYMNET_ENV>/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