-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
58 lines (50 loc) · 1.23 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
stages:
- build
- deploy
.stg-vars:
variables:
ENVIRONMENT: stg
MODE: s
IMAGE_URL: ${DOCKER_REGISTRY}/aic22-frontend:stg
SWARM_MASTER_NODE: ${STG_SWARM_MASTER_NODE}
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
.production-vars:
variables:
ENVIRONMENT: prod
MODE: p
IMAGE_URL: ${DOCKER_REGISTRY}/aic22-frontend:${CI_COMMIT_SHORT_SHA}
SWARM_MASTER_NODE: ${PRD_SWARM_MASTER_NODE}
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
.build:
stage: build
image: ${DOCKER_REGISTRY}/docker:19.03.12
tags:
- docker
script:
- docker build . --build-arg MODE=${MODE} -t ${IMAGE_URL}
- docker push ${IMAGE_URL}
.deploy:
stage: deploy
before_script:
- chmod -R 700 $SSH_PRIVATE_KEY
- ssh -i $SSH_PRIVATE_KEY -o "StrictHostKeyChecking=no" ${SWARM_MASTER_NODE} -t "docker pull ${IMAGE_URL}"
script:
- ssh -i $SSH_PRIVATE_KEY -o "StrictHostKeyChecking=no" ${SWARM_MASTER_NODE} -t "docker service update --image ${IMAGE_URL} aic_frontend_${ENVIRONMENT}"
stg-build:
extends:
- .stg-vars
- .build
production-build:
extends:
- .production-vars
- .build
stg-deploy:
extends:
- .stg-vars
- .deploy
production-deploy:
extends:
- .production-vars
- .deploy