-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.yml
431 lines (392 loc) · 11.3 KB
/
.drone.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
---
kind: pipeline
name: Build Image
type: kubernetes
platform:
os: linux
arch: amd64
steps:
- name: build_and_push
pull: if-not-exists
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind:latest
environment:
AWS_ACCESS_KEY_ID:
from_secret: DEV_EGAR_PUBLIC_SITE_UI_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: DEV_EGAR_PUBLIC_SITE_UI_AWS_SECRET_ACCESS_KEY
DOCKER_REGISTRY_URL: 340268328991.dkr.ecr.eu-west-2.amazonaws.com
REPO: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/egar/public-site-ui
commands:
- source ./ops/build_and_push.sh
settings:
group: build-stage
- name: Unit Tests
pull: if-not-exists
image: node:18-alpine3.18
commands:
- export NOTIFY_API_KEY=dummy
- cd src
- npm install
- npm run test-drone
settings:
group: build-stage
when:
event:
- push
- pull_request
- name: scan-image
pull: always
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/trivy/client:latest
failure: ignore
resources:
limits:
cpu: 1000
memory: 1024Mi
environment:
IMAGE_NAME: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/egar/public-site-ui:${DRONE_COMMIT}
IGNORE_UNFIXED: true
when:
event:
- push
depends_on:
- build_and_push
services:
- name: docker
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind
volumes:
- name: dockersock
temp: {}
trigger:
event:
- push
---
kind: pipeline
name: Dev Deployment
type: kubernetes
platform:
os: linux
arch: amd64
steps:
- name: Deploy to DEV
pull: if-not-exists
image: quay.io/ukhomeofficedigital/kd
commands:
- source ./ops/dev_deploy_vars.sh
- source ./ops/deploy.sh
environment:
INGRESS_CLASS: nginx-internal
INSECURE_SKIP_TLS_VERIFY: true
KUBE_NAMESPACE: egar-dev
NODE_ENV: development
DEV_BASE_URL:
from_secret: DEV_BASE_URL
DEV_KUBE_SERVER:
from_secret: DEV_KUBE_SERVER
DEV_KUBE_TOKEN:
from_secret: DEV_KUBE_TOKEN
DEV_URL_SERVICE:
from_secret: DEV_URL_SERVICE
trigger:
event:
- tag
ref:
- refs/tags/release*
---
kind: pipeline
name: Test Deployment
type: kubernetes
platform:
os: linux
arch: amd64
steps:
- name: Deploy to Test
pull: if-not-exists
image: quay.io/ukhomeofficedigital/kd
commands:
- source ./ops/test_deploy_vars.sh
- source ./ops/test_deploy.sh
environment:
INGRESS_CLASS: nginx-internal
INSECURE_SKIP_TLS_VERIFY: true
KUBE_NAMESPACE: egar-test
NODE_ENV: testing
TEST_BASE_URL:
from_secret: TEST_BASE_URL
TEST_KUBE_SERVER:
from_secret: TEST_KUBE_SERVER
TEST_KUBE_TOKEN:
from_secret: TEST_KUBE_TOKEN
# DEV_URL_SERVICE:
# from_secret: DEV_URL_SERVICE
trigger:
event:
- tag
ref:
- refs/tags/deploy-test*
---
kind: pipeline
name: SIT Deployment
type: kubernetes
platform:
os: linux
arch: amd64
steps:
- name: Deploy to SIT
pull: if-not-exists
image: quay.io/ukhomeofficedigital/kd
commands:
- source ./ops/sit_deploy_vars.sh
- source ./ops/deploy.sh
environment:
INGRESS_CLASS: nginx-internal
INSECURE_SKIP_TLS_VERIFY: true
KUBE_NAMESPACE: egar-sit
NODE_ENV: sit
SIT_BASE_URL:
from_secret: SIT_BASE_URL
SIT_BASE_URL_SERVICE:
from_secret: SIT_BASE_URL_SERVICE
SIT_KUBE_SERVER:
from_secret: SIT_KUBE_SERVER
SIT_KUBE_TOKEN:
from_secret: SIT_KUBE_TOKEN
- name: Get_the_Dynamic_DB_creds
pull: if-not-exists
image: quay.io/ukhomeofficedigital/kd
commands:
- export KUBE_SERVER=$${SIT_KUBE_SERVER}
- export KUBE_TOKEN=$${SIT_KUBE_TOKEN}
- echo "export E2E_FRONT_END_DB_USER=$(kd run get secret appdbcreds --template={{.data.FRONTENDDBUSER}} | base64 -d)" > db_creds
- echo "export E2E_FRONT_END_DB_PASSWORD=$(kd run get secret appdbcreds --template={{.data.FRONTENDDBPASSWORD}} | base64 -d)" >> db_creds
- echo "export E2E_BACK_END_DB_USER=$(kd run get secret appdbcreds --template={{.data.BACKENDDBUSER}} | base64 -d)" >> db_creds
- echo "export E2E_BACK_END_DB_PASSWORD=$(kd run get secret appdbcreds --template={{.data.BACKENDDBPASSWORD}} | base64 -d)" >> db_creds
environment:
INGRESS_CLASS: nginx-internal
INSECURE_SKIP_TLS_VERIFY: true
KUBE_NAMESPACE: egar-sit
NODE_ENV: sit
SIT_KUBE_SERVER:
from_secret: SIT_KUBE_SERVER
SIT_KUBE_TOKEN:
from_secret: SIT_KUBE_TOKEN
- name: End to End tests
pull: if-not-exists
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind:latest
commands:
- source db_creds
- "docker run --rm -t --name e2e-test_${DRONE_BUILD_NUMBER} -e PROTOCOL=$${E2E_PROTOCOL} -e BASE_URL=$${E2E_BASE_URL} -e E2E_SMTP_SERVER=$${E2E_SMTP_SERVER} -e E2E_SMTP_PORT=$${E2E_SMTP_PORT} -e E2E_INDIVIDUAL_USER_USERNAME=$${E2E_INDIVIDUAL_USER_USERNAME} -e E2E_INDIVIDUAL_USER_PASSWORD=$${E2E_INDIVIDUAL_USER_PASSWORD} -e E2E_ORGANISATION_USER_USERNAME=$${E2E_ORGANISATION_USER_USERNAME} -e E2E_ORGANISATION_USER_PASSWORD=$${E2E_ORGANISATION_USER_PASSWORD} -e E2E_FRONT_END_DB_HOST=$${E2E_FRONT_END_DB_HOST} -e E2E_FRONT_END_DB_NAME=$${E2E_FRONT_END_DB_NAME} -e E2E_FRONT_END_DB_USER=$E2E_FRONT_END_DB_USER -e E2E_FRONT_END_DB_PASSWORD=$E2E_FRONT_END_DB_PASSWORD -e E2E_BACK_END_DB_HOST=$${E2E_BACK_END_DB_HOST} -e E2E_BACK_END_DB_NAME=$${E2E_BACK_END_DB_NAME} -e E2E_BACK_END_DB_USER=$E2E_BACK_END_DB_USER -e E2E_BACK_END_DB_PASSWORD=$E2E_BACK_END_DB_PASSWORD quay.io/ukhomeofficedigital/egar-e2e-test:latest\n"
- rm db_creds
environment:
E2E_BACK_END_DB_HOST:
from_secret: E2E_BACK_END_DB_HOST
E2E_BACK_END_DB_NAME:
from_secret: E2E_BACK_END_DB_NAME
E2E_BASE_URL:
from_secret: E2E_BASE_URL
E2E_FRONT_END_DB_HOST:
from_secret: E2E_FRONT_END_DB_HOST
E2E_FRONT_END_DB_NAME:
from_secret: E2E_FRONT_END_DB_NAME
E2E_INDIVIDUAL_USER_PASSWORD:
from_secret: E2E_INDIVIDUAL_USER_PASSWORD
E2E_INDIVIDUAL_USER_USERNAME:
from_secret: E2E_INDIVIDUAL_USER_USERNAME
E2E_ORGANISATION_USER_PASSWORD:
from_secret: E2E_ORGANISATION_USER_PASSWORD
E2E_ORGANISATION_USER_USERNAME:
from_secret: E2E_ORGANISATION_USER_USERNAME
E2E_PROTOCOL:
from_secret: E2E_PROTOCOL
E2E_SMTP_PORT:
from_secret: E2E_SMTP_PORT
E2E_SMTP_SERVER:
from_secret: E2E_SMTP_SERVER
services:
- name: docker
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind
volumes:
- name: dockersock
temp: {}
trigger:
branch:
- master
- hotfix/*
event:
- push
---
kind: pipeline
name: Staging Deployment
type: kubernetes
platform:
os: linux
arch: amd64
steps:
- name: Deploy to Staging
pull: if-not-exists
image: quay.io/ukhomeofficedigital/kd
commands:
- source ./ops/staging_deploy_vars.sh
- source ./ops/deploy.sh
environment:
DOCKER_REGISTRY_URL:
from_secret: DOCKER_REGISTRY_URL
INGRESS_CLASS: nginx-external
INSECURE_SKIP_TLS_VERIFY: true
KUBE_NAMESPACE: egar-staging
NODE_ENV: staging
STAGING_BASE_URL:
from_secret: STAGING_BASE_URL
STAGING_BASE_URL_SERVICE:
from_secret: STAGING_BASE_URL_SERVICE
STAGING_KUBE_SERVER:
from_secret: STAGING_KUBE_SERVER
STAGING_KUBE_TOKEN:
from_secret: STAGING_KUBE_TOKEN
trigger:
branch:
- master
- hotfix/*
- sGAR*
event:
- promote
target:
exclude:
- production
include:
- staging
---
kind: pipeline
name: Prod Deployment
type: kubernetes
platform:
os: linux
arch: amd64
steps:
- name: Deploy to Production
pull: if-not-exists
image: quay.io/ukhomeofficedigital/kd
commands:
- source ./ops/prod_deploy_vars.sh
- source ./ops/prod_deploy.sh
environment:
DOCKER_REGISTRY_URL:
from_secret: DOCKER_REGISTRY_URL
INGRESS_CLASS: nginx-external
INSECURE_SKIP_TLS_VERIFY: true
KUBE_NAMESPACE: egar-production
NODE_ENV: production
PRODUCTION_BASE_URL_SERVICE:
from_secret: PRODUCTION_BASE_URL_SERVICE
PRODUCTION_KUBE_SERVER:
from_secret: PRODUCTION_KUBE_SERVER
PRODUCTION_KUBE_TOKEN:
from_secret: PRODUCTION_KUBE_TOKEN
- name: Notify Slack
pull: if-not-exists
image: plugins/slack
settings:
channel: sgar-dev
webhook:
from_secret: SLACK_WEBHOOK
template: >
{{#success build.status}}
*Deployment* {{repo.name}} - *SUCCESS*
Author: {{build.author}}
Job: <{{build.link}}|#{{build.number}}>
Duration: {{since job.started}}
Message: {{build.message}}
{{else}}
*Deployment* {{repo.name}} - *FAILURE*
Author: {{build.author}}
Job: <{{build.link}}|#{{build.number}}>
Duration: {{since job.started}}
Message: {{build.message}}
{{/success}}
environment:
SLACK_WEBHOOK:
from_secret: SLACK_WEBHOOK
trigger:
branch:
- master
- hotfix/*
event:
- promote
target:
include:
- production
---
kind: pipeline
name: CRON Scanning
type: kubernetes
platform:
os: linux
arch: amd64
steps:
- name: build_and_push_cron
pull: if-not-exists
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind:latest
environment:
AWS_ACCESS_KEY_ID:
from_secret: DEV_EGAR_PUBLIC_SITE_UI_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: DEV_EGAR_PUBLIC_SITE_UI_AWS_SECRET_ACCESS_KEY
DOCKER_REGISTRY_URL: 340268328991.dkr.ecr.eu-west-2.amazonaws.com
REPO: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/egar/public-site-ui
commands:
- source ./ops/build_and_push.sh
settings:
group: build-stage
- name: scan-image-cron
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/trivy/client:latest
resources:
limits:
cpu: 1000
memory: 1024Mi
environment:
IMAGE_NAME: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/egar/public-site-ui:${DRONE_COMMIT}
IGNORE_UNFIXED: true
when:
event:
- cron
depends_on: build_and_push_cron
cron:
- scheduled_vulnerability_scan
- name: Notify Slack CRON
pull: if-not-exists
image: plugins/slack
settings:
channel: sgar-dev
webhook:
from_secret: SLACK_WEBHOOK
template: >
{{#success build.status}}
*Image Security Scan* CRON Job has {{build.status}}
Author: {{build.author}}
Job: <{{build.link}}|#{{build.number}}>
Duration: {{since job.started}}
Message: {{build.message}}
{{else}}
*Image Security Scan* CRON Job has {{build.status}}
*Deployment* {{repo.name}} - *FAILURE*
Author: {{build.author}}
Job: <{{build.link}}|#{{build.number}}>
Duration: {{since job.started}}
Message: {{build.message}}
Event:
{{/success}}
environment:
SLACK_WEBHOOK:
from_secret: SLACK_WEBHOOK
services:
- name: docker
image: 340268328991.dkr.ecr.eu-west-2.amazonaws.com/acp/dind
volumes:
- name: dockersock
temp: {}
trigger:
branch:
- master
event:
- cron
cron:
- scheduled_vulnerability_scan