forked from medialab/hyphe
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
72 lines (65 loc) · 2.08 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
image: docker:stable
stages:
- build
- deploy
variables:
BACKEND_IMAGE_NAME: $CI_REGISTRY/scpomedialab/hyphe_backend
CRAWLER_IMAGE_NAME: $CI_REGISTRY/scpomedialab/hyphe_crawler
FRONTEND_IMAGE_NAME: $CI_REGISTRY/scpomedialab/hyphe_frontend
before_script:
- VERSION=$(echo $CI_COMMIT_TAG | sed -nre 's/^v([0-9.]+)$/\1/p')
- if [ -n "${VERSION}" ]; then IMAGE_TAG=${VERSION}; else IMAGE_TAG=${CI_COMMIT_REF_SLUG}; fi
build_backend_image:
stage: build
script:
- docker build -t $BACKEND_IMAGE_NAME:$IMAGE_TAG -f Dockerfile .
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker push $BACKEND_IMAGE_NAME:$IMAGE_TAG
environment:
name: $CI_COMMIT_REF_SLUG
only:
- staging
- prod
- tags
build_crawler_image:
stage: build
script:
- docker build -t $CRAWLER_IMAGE_NAME:$IMAGE_TAG -f ./hyphe_backend/crawler/Dockerfile ./hyphe_backend/crawler/
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker push $CRAWLER_IMAGE_NAME:$IMAGE_TAG
environment:
name: $CI_COMMIT_REF_SLUG
only:
- staging
- prod
- tags
build_frontend_image:
stage: build
script:
- docker build -t $FRONTEND_IMAGE_NAME:$IMAGE_TAG -f ./hyphe_frontend/Dockerfile ./hyphe_frontend/
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker push $FRONTEND_IMAGE_NAME:$IMAGE_TAG
environment:
name: $CI_COMMIT_REF_SLUG
only:
- staging
- prod
- tags
deploy:
image:
name: jrisp/kubehelper:latest
entrypoint: [""]
stage: deploy
script:
- kubectl config set-cluster k8s --server="$KUBE_URL" --certificate-authority="$KUBE_CA_PEM_FILE"
- kubectl config set-credentials gitlab-admin --token="$KUBE_TOKEN"
- kubectl config set-context default --cluster=k8s --user=gitlab-admin
- kubectl config use-context default
- kubectl -n $STACK rollout restart deployment backend
- kubectl -n $STACK rollout restart deployment crawler
- kubectl -n $STACK rollout restart deployment frontend
environment:
name: $CI_COMMIT_REF_SLUG
only:
- staging
- prod