-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
90 lines (82 loc) · 3.22 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
image: docker:latest
stages:
- build
- deploy
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
CI_REGISTRY_IMAGE: ebispot/gwas-deposition-template
# always build an image tagged with the commit SHA from master
build:
stage: build
script:
- echo "$DOCKER_HUB_PASSWORD" > dhpw.txt
- docker login -u "${DOCKER_HUB_USER}" --password-stdin < dhpw.txt
- docker pull $CI_REGISTRY_IMAGE:latest
- docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .
# - docker run $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA pytest
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
only:
- master
# if a tag is created create an images with the tag and a latest
build_release:
variables:
GIT_STRATEGY: none
stage: build
script:
- echo "$DOCKER_HUB_PASSWORD" > dhpw.txt
- docker login -u "${DOCKER_HUB_USER}" --password-stdin < dhpw.txt
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker push $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
only:
- tags
deploy_sandbox:
image: dtzar/helm-kubectl:2.13.1
stage: deploy
script:
- echo "Deploy to staging server"
- mkdir -p /root/.kube
- echo ${PLIVE_KUBECONFIG} | base64 -d > /root/.kube/config
- helm init --stable-repo-url https://charts.helm.sh/stable
- helm delete --purge gwas-template-service-dev || true
- helm install --name gwas-template-service-dev --set image.env.basePath=/gwas/deposition/template,service.name=gwas-template-service-dev,service.type=NodePort,service.port=8080,k8Namespace=gwas-dev,ingress.name=template-ingress-dev,image.volume.claimName=gwas-dev-depo-logs,image.repository=$CI_REGISTRY_IMAGE,image.tag=$CI_COMMIT_SHA ./k8chart/ --wait
environment:
name: sandbox
only:
- master
deploy_fallback:
image: dtzar/helm-kubectl:2.13.1
stage: deploy
script:
- echo "Deploy to production fallback server"
- mkdir -p /root/.kube
- echo ${PFALLBACK_KUBECONFIG} | base64 -d > /root/.kube/config
- helm init --stable-repo-url https://charts.helm.sh/stable
- helm delete --purge gwas-template-service || true
- helm install --name gwas-template-service --set image.env.basePath=/gwas/deposition/template,service.type=NodePort,k8Namespace=gwas,image.repository=$CI_REGISTRY_IMAGE,image.tag=$CI_COMMIT_SHA ./k8chart/ --wait
environment:
name: fallback
when: manual
only:
- tags
deploy_prod:
image: dtzar/helm-kubectl:2.13.1
stage: deploy
script:
- echo "Deploy to production server"
- mkdir -p /root/.kube
- echo ${PLIVE_KUBECONFIG} | base64 -d > /root/.kube/config
- helm init --stable-repo-url https://charts.helm.sh/stable
- helm delete --purge gwas-template-service || true
- helm install --name gwas-template-service --set image.env.basePath=/gwas/deposition/template,service.type=NodePort,k8Namespace=gwas,image.repository=$CI_REGISTRY_IMAGE,image.tag=$CI_COMMIT_SHA ./k8chart/ --wait
environment:
name: production
url: http://www.ebi.ac.uk/gwas/submission/template
when: manual
only:
- tags