-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
130 lines (115 loc) · 3.24 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
variables:
REGISTRY: $CI_REGISTRY
IMAGE_TAG: $CI_REGISTRY_IMAGE
DOCKER_HOST: tcp://localhost:2375
DOCKER_REGISTRY: 285302907374.dkr.ecr.eu-central-1.amazonaws.com
AWS_DEFAULT_REGION: eu-central-1
image: node:14
stages:
- dependencies
- lint
- build
- test
- dockerize
- deploy
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- sys-src/backend/node_modules/
- sys-src/frontend/node_modules/
default:
tags:
- cluster
install_dependencies_backend:
stage: dependencies
script:
- cd sys-src/backend
- npm install
install_dependencies_frontend:
stage: dependencies
script:
- cd sys-src/frontend
- npm install
lint_backend:
stage: lint
script:
- cd sys-src/backend
- npm install
- npm run lint
lint_frontend:
stage: lint
script:
- cd sys-src/frontend
- npm install
- npm run lint
build_backend:
stage: build
script:
- cd sys-src/backend
- npm install
- npm run build
build_frontend:
stage: build
script:
- cd sys-src/frontend
- npm install
- npm run build
test_backend:
stage: test
script:
- cd sys-src/backend
- npm install
- npm run test
test_frontend:
stage: test
script:
- cd sys-src/frontend
- npm install
- npm run test
build_docker_backend:
stage: dockerize
image: docker:stable
services:
- docker:18.09.7-dind
only:
- main
before_script:
- apk add --no-cache curl jq python3 py3-pip
- pip install awscli
- aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_REGISTRY
- aws --version
script:
- cd sys-src/backend
- docker build -t $DOCKER_REGISTRY/frontend:latest -t $DOCKER_REGISTRY/frontend:$CI_PIPELINE_IID .
- docker build -t $DOCKER_REGISTRY/backend:latest -t $DOCKER_REGISTRY/backend:$CI_PIPELINE_IID .
- docker push $DOCKER_REGISTRY/backend:latest
- docker push $DOCKER_REGISTRY/backend:$CI_PIPELINE_IID
build_docker_frontend:
stage: dockerize
image: docker:stable
services:
- docker:18.09.7-dind
only:
- main
before_script:
- apk add --no-cache curl jq python3 py3-pip
- pip install awscli
- aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_REGISTRY
- aws --version
script:
- cd sys-src/frontend
- docker build -t $DOCKER_REGISTRY/frontend:latest -t $DOCKER_REGISTRY/frontend:$CI_PIPELINE_IID .
- docker push $DOCKER_REGISTRY/frontend:latest
- docker push $DOCKER_REGISTRY/frontend:$CI_PIPELINE_IID
deploy_production:
stage: deploy
image:
name: bitnami/kubectl:1.14
entrypoint: [""]
environment: eks
only:
- main
script:
- kubectl config set-context --current --namespace=fireforcedefense-27426248
- kubectl set image deployment frontend frontend=$DOCKER_REGISTRY/frontend:latest --namespace=fireforcedefense-27426248
- kubectl set image deployment backend backend=$DOCKER_REGISTRY/backend:latest --namespace=fireforcedefense-27426248