-
Notifications
You must be signed in to change notification settings - Fork 12
/
.gitlab-ci.yml
185 lines (179 loc) · 5.36 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
stages:
- os_build
- aws_build
variables:
AWS_TAG: latest
OS_TAG: $CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA
os-backend-build:
stage: os_build
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: always
allow_failure: true
- when: manual
allow_failure: true
image:
name: docker:latest
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ''
services:
- name: docker:stable-dind
command:
- '--tls=false'
- '--host=tcp://0.0.0.0:2375'
before_script:
- docker login -u $OPENSHIFT_USER -p $OPENSHIFT_TOKEN $REGISTRY_URL
- cd backend
script:
- DOCKER_BUILDKIT=1 docker build -t backend-ci:$OS_TAG .
- docker tag backend-ci:$OS_TAG $REGISTRY_URL/$OPENSHIFT_PROJECTNAME/backend-ci:$OS_TAG
- docker push $REGISTRY_URL/$OPENSHIFT_PROJECTNAME/backend-ci:$OS_TAG
os-frontend-build:
stage: os_build
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: always
allow_failure: true
- when: manual
allow_failure: true
image:
name: docker:latest
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ''
services:
- name: docker:stable-dind
command:
- '--tls=false'
- '--host=tcp://0.0.0.0:2375'
before_script:
- docker login -u $OPENSHIFT_USER -p $OPENSHIFT_TOKEN $REGISTRY_URL
- cd frontend
script:
- DOCKER_BUILDKIT=1 docker build -t frontend-ci:$OS_TAG .
- docker tag frontend-ci:$OS_TAG $REGISTRY_URL/$OPENSHIFT_PROJECTNAME/frontend-ci:$OS_TAG
- docker push $REGISTRY_URL/$OPENSHIFT_PROJECTNAME/frontend-ci:$OS_TAG
openshift-deploy:
stage: os_build
needs: ['os-frontend-build', 'os-backend-build']
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: always
allow_failure: true
- when: manual
allow_failure: true
image:
name: openshift/origin-cli
before_script:
# - curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-linux-amd64 -o /usr/local/bin/helm
# - chmod +x /usr/local/bin/helm
- curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/3.11.1/helm-linux-amd64 -o /usr/local/bin/helm
- chmod +x /usr/local/bin/helm
- helm version
script:
- echo "login to Openshift"
- echo -e $K8S_SECRET_CERT > backend/certs/cert.pem
- echo -e $K8S_SECRET_KEY > backend/certs/key.pem
- oc login --token=$OPENSHIFT_TOKEN --server=$OPENSHIFT_SERVER
- oc project $OPENSHIFT_PROJECTNAME
- echo "Run Helm for Openshift Bailo-Dev"
- cd infrastructure/helm/bailo/
- |
cat > ci-dev.yaml << EOF
---
# Overwrite values.yaml
config:
ui:
banner:
enabled: "true"
text: "BAILO DEVELOPMENT"
colour: "#2B71C7"
# Bailo
image:
frontendRepository: "$FRONTEND_REPO"
frontendTag: $OS_TAG
backendRepository: "$BACKEND_REPO"
backendTag: $OS_TAG
# Used for openshift
route:
enabled: true
appPublicRoute: $ROUTE
# Oauth cognito config
oauth:
enabled: false
# Mongo
mongodb:
auth:
passwords:
- $MONGO_PWD
usernames:
- $MONGO_USR
openshift:
namespace: $OPENSHIFT_PROJECTNAME
EOF
- cat ci-dev.yaml
- helm dependency update
- helm upgrade --install --values ci-dev.yaml $HELM_DEP .
aws-backend-build:
stage: aws_build
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: always
allow_failure: true
- when: manual
allow_failure: true
image:
name: docker:latest
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ''
services:
- name: docker:stable-dind
command:
- '--tls=false'
- '--host=tcp://0.0.0.0:2375'
before_script:
- apk add --no-cache curl jq python3 py3-pip
- pip install awscli --break-system-packages
- aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_REGISTRY
- aws --version
- docker info
- docker --version
- cd backend
script:
- DOCKER_BUILDKIT=1 docker build -t $DOCKER_REGISTRY/$APP_NAME_BACKEND:$AWS_TAG .
- docker tag $DOCKER_REGISTRY/$APP_NAME_BACKEND:$AWS_TAG $DOCKER_REGISTRY/$APP_NAME_BACKEND:$OS_TAG
- docker push $DOCKER_REGISTRY/$APP_NAME_BACKEND:$AWS_TAG
- docker push $DOCKER_REGISTRY/$APP_NAME_BACKEND:$OS_TAG
aws-frontend-build:
stage: aws_build
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: always
allow_failure: true
- when: manual
allow_failure: true
image:
name: docker:latest
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ''
services:
- name: docker:stable-dind
command:
- '--tls=false'
- '--host=tcp://0.0.0.0:2375'
before_script:
- apk add --no-cache curl jq python3 py3-pip
- pip install awscli --break-system-packages
- aws ecr get-login-password | docker login --username AWS --password-stdin $DOCKER_REGISTRY
- aws --version
- docker info
- docker --version
- cd frontend
script:
- DOCKER_BUILDKIT=1 docker build -t $DOCKER_REGISTRY/$APP_NAME_FRONTEND:$AWS_TAG .
- docker tag $DOCKER_REGISTRY/$APP_NAME_FRONTEND:$AWS_TAG $DOCKER_REGISTRY/$APP_NAME_FRONTEND:$OS_TAG
- docker push $DOCKER_REGISTRY/$APP_NAME_FRONTEND:$AWS_TAG
- docker push $DOCKER_REGISTRY/$APP_NAME_FRONTEND:$OS_TAG