-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
808 lines (748 loc) · 25.1 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
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
include:
- template: Jobs/Dependency-Scanning.gitlab-ci.yml
#- template: SAST.gitlab-ci.yml
#- template: DAST.gitlab-ci.yml
variables:
PYTHON_VER: "3.11"
SECURE_ANALYZERS_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers"
DS_DISABLE_DIND: "true"
SAST_DISABLE_DIND: "true"
CI_APPLICATION_TAG: $CI_COMMIT_SHA-api-stage
DAST_WEBSITE: https://adios-stage.orr.noaa.gov
DAST_USE_AJAX_SPIDER: "true"
stages:
- test
- build
- verify
- deploy_db
- deploy
- maintenance
test_develop:
stage: test
image: registry.orr.noaa.gov/erd/centos-conda/ubuntu/ubuntuforge-python$PYTHON_VER
tags:
- docker
- linux
except:
- schedules
before_script:
- apt update
- apt upgrade -y
# mongod fails if the tzdata package is missing
- echo 'tzdata tzdata/Areas select America' | debconf-set-selections
- echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections
- DEBIAN_FRONTEND="noninteractive" apt install -y tzdata
script:
# install all the requirements
- >
conda install -y
python=$PYTHON_VER
--file adios_db/conda_requirements.txt
--file adios_db/conda_requirements_optional.txt
--file adios_db/conda_requirements_test.txt
--file web_api/conda_requirements.txt
# configure and start mongodb
# mongo should have been installed by conda, but conda doesn't reserve
# places for the logs, the database, and the pidfile
# note: maybe we should update the test config so we don't need this??
# and then we could save the logs, etc as an artifact as well.
- mkdir /var/lib/mongo
- mkdir /var/log/mongodb
- mkdir /var/run/mongodb
# We can start the docker container manually like this:
# docker run --volume $(pwd)/git_repos/oil_database:/oil_database -it registry.orr.noaa.gov/erd/centos-conda/ubuntu/ubuntuforge-python3.11 /bin/bash
- mongod --config mongo_config_test.yml &
# apt-get install -y lsof
# lsof -nP -iTCP -sTCP:LISTEN # see if mongod is listening
# Install & test the adios_db package
- cd adios_db
- pip install ./
- pytest --mongo adios_db/test
# Install & test the adios_db_api package
- cd ../web_api
- pip install ./
- pytest adios_db_api/tests
build_api:
stage: build
tags:
- build
except:
- schedules
variables:
# URI format: <hostname>/<group>/<subgroup>/<project>/<module-name>
# Should be something like: registry.orr.noaa.gov/gnome/oil_database/oil_database/api
IMAGE_TAG_DBG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-api-dbg
IMAGE_TAG_PROD: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-api
before_script:
- mv $ADIOS_STAGE_CONTAINER_KEY ./web_api/key
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oildb-deploy.git
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -f web_api/dockerfile -t $IMAGE_TAG_DBG --build-arg KEY_FILE="./web_api/key" --build-arg PYTHON_VER=$PYTHON_VER
# apparently there is a timeout on the docker session, so we re-login
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push $IMAGE_TAG_DBG
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -f web_api/dockerfile_prod -t $IMAGE_TAG_PROD --build-arg KEY_FILE="./web_api/key" --build-arg PYTHON_VER=$PYTHON_VER
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push $IMAGE_TAG_PROD
build_client:
stage: build
tags:
- build
except:
- schedules
variables:
# Should be something like: registry.orr.noaa.gov/gnome/oil_database/oil_database/client
IMAGE_TAG_DBG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-client-dbg
IMAGE_TAG_PROD: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-client
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oildb-deploy.git
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -f web_client/dockerfile -t $IMAGE_TAG_DBG
# apparently there is a timeout on the docker session, so we re-login
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push $IMAGE_TAG_DBG
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -f web_client/dockerfile_prod -t $IMAGE_TAG_PROD
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push $IMAGE_TAG_PROD
scan-api:
stage: verify
image: "$CS_ANALYZER_IMAGE"
allow_failure: true
variables:
CS_ANALYZER_IMAGE: $SECURE_ANALYZERS_PREFIX/klar:$CS_MAJOR_VERSION
DOCKER_IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-api
# By default, use the latest clair vulnerabilities database, however, allow it to be overridden here with a specific image
# to enable container scanning to run offline, or to provide a consistent list of vulnerabilities for integration testing purposes
CLAIR_DB_IMAGE_TAG: "latest"
CLAIR_DB_IMAGE: "$SECURE_ANALYZERS_PREFIX/clair-vulnerabilities-db:$CLAIR_DB_IMAGE_TAG"
# Override the GIT_STRATEGY variable in your `.gitlab-ci.yml` file and set it to `fetch` if you want to provide a `clair-whitelist.yml`
# file. See https://docs.gitlab.com/ee/user/application_security/container_scanning/index.html#overriding-the-container-scanning-template
# for details
GIT_STRATEGY: none
services:
- name: $CLAIR_DB_IMAGE
alias: clair-vulnerabilities-db
script:
- /analyzer run
artifacts:
reports:
container_scanning: gl-container-scanning-report.json
dependencies: []
rules:
- if: $CONTAINER_SCANNING_DISABLED
when: never
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH &&
$GITLAB_FEATURES =~ /\bcontainer_scanning\b/
scan-client:
stage: verify
image: "$CS_ANALYZER_IMAGE"
allow_failure: true
variables:
CS_ANALYZER_IMAGE: $SECURE_ANALYZERS_PREFIX/klar:$CS_MAJOR_VERSION
DOCKER_IMAGE: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-client
# By default, use the latest clair vulnerabilities database, however, allow it to be overridden here with a specific image
# to enable container scanning to run offline, or to provide a consistent list of vulnerabilities for integration testing purposes
CLAIR_DB_IMAGE_TAG: "latest"
CLAIR_DB_IMAGE: "$SECURE_ANALYZERS_PREFIX/clair-vulnerabilities-db:$CLAIR_DB_IMAGE_TAG"
# Override the GIT_STRATEGY variable in your `.gitlab-ci.yml` file and set it to `fetch` if you want to provide a `clair-whitelist.yml`
# file. See https://docs.gitlab.com/ee/user/application_security/container_scanning/index.html#overriding-the-container-scanning-template
# for details
GIT_STRATEGY: none
services:
- name: $CLAIR_DB_IMAGE
alias: clair-vulnerabilities-db
script:
- /analyzer run
artifacts:
reports:
container_scanning: gl-container-scanning-report.json
dependencies: []
rules:
- if: $CONTAINER_SCANNING_DISABLED
when: never
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH &&
$GITLAB_FEATURES =~ /\bcontainer_scanning\b/
deploy_mongodb_stage:
stage: deploy_db
only:
- develop
except:
- schedules
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
on_stop: stop_mongodb_stage
variables:
IMAGE_TAG: mongo:4.4.6
CONTAINER_NAME: mongodb
APP_NETWORK: adios_net
PORT_MAPPING: 127.0.0.1:27017:27017
DB_VOLUME: dbdata
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- >
docker volume inspect $DB_VOLUME >/dev/null 2>&1 ||
docker volume create $DB_VOLUME
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
# The volume permissions are important here, so we need to set a user:group
# when starting the container.
# Right now they are set to james.makela:adios-dev so developers can manage
# the volume external to the docker container. We will need to change this
# on the public server.
- >
docker run -d -p $PORT_MAPPING --name $CONTAINER_NAME --network $APP_NETWORK
-v $DB_VOLUME:/data/db
--restart unless-stopped $IMAGE_TAG
tags:
- adios-stage
- deploy
stop_mongodb_stage:
stage: deploy_db
when: manual
only:
- develop
environment:
name: stage
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: mongodb
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-stage
- deploy
deploy_mongodb_public:
stage: deploy_db
only:
- production
environment:
name: public
url: https://adios.orr.noaa.gov
on_stop: stop_mongodb_public
variables:
IMAGE_TAG: mongo:4.4.6
CONTAINER_NAME: mongodb
APP_NETWORK: adios_net
PORT_MAPPING: 127.0.0.1:27017:27017
DB_VOLUME: dbdata
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- >
docker volume inspect $DB_VOLUME >/dev/null 2>&1 ||
docker volume create $DB_VOLUME
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
- >
docker run -d --name $CONTAINER_NAME --network $APP_NETWORK --restart unless-stopped
-p $PORT_MAPPING
-v $DB_VOLUME:/data/db $IMAGE_TAG
tags:
- adios-prod
- deploy
stop_mongodb_public:
stage: deploy_db
only:
- production
when: manual
environment:
name: public
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: mongodb
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-prod
- deploy
deploy_api_stage:
stage: deploy
only:
- develop
except:
- schedules
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
on_stop: stop_api_stage
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-api-dbg
CONTAINER_NAME: adios_db_web_api
APP_NETWORK: adios_net
PORT_MAPPING: 127.0.0.1:8084:9898
REPO_VOLUME: noaa_data_repo
KC_CONFIG_VOLUME: adiosdb_kc_config
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- >
docker volume inspect $REPO_VOLUME >/dev/null 2>&1 ||
docker volume create $REPO_VOLUME
- >
docker volume inspect $KC_CONFIG_VOLUME >/dev/null 2>&1 ||
docker volume create $KC_CONFIG_VOLUME
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
- >
docker run -d -p $PORT_MAPPING --name $CONTAINER_NAME
-e MONGODB_WRITEABLE=true
-e REFRESH_INTERNAL_DB=$REFRESH_INTERNAL_DB
--network $APP_NETWORK
-v $REPO_VOLUME:/data/git_repos
-v $KC_CONFIG_VOLUME:/data/kc_config
--restart unless-stopped $IMAGE_TAG
- docker ps
- docker logs $CONTAINER_NAME
tags:
- adios-stage
- deploy
stop_api_stage:
stage: deploy
only:
- develop
when: manual
environment:
name: stage
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: adios_db_web_api
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-stage
- deploy
deploy_oauth_api_stage:
stage: deploy
only:
- develop
except:
- schedules
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
on_stop: stop_oauth_api_stage
variables:
IMAGE_TAG: registry.orr.noaa.gov/it/oauth2-proxy:master
CONTAINER_NAME: auth_web_api
APP_NETWORK: adios_net
PORT_MAPPING: 8004:4180
OAUTH2_PROXY_PROVIDER: keycloak-oidc
OAUTH2_PROXY_CLIENT_ID: adios-database
OAUTH2_PROXY_REDIRECT_URL: https://adios-stage.orr.noaa.gov/oauth2/callback
OAUTH2_PROXY_OIDC_ISSUER_URL: https://auth.orr.noaa.gov/auth/realms/ORR
OAUTH2_PROXY_EMAIL_DOMAINS: noaa.gov
OAUTH2_PROXY_COOKIE_SECRET: penguinsarereallythebest
OAUTH2_PROXY_UPSTREAMS: http://adios_db_web_api:9898
OAUTH2_PROXY_COOKIE_DOMAIN: https://adios-stage.orr.noaa.gov
OAUTH2_PROXY_HTTP_ADDRESS: 0.0.0.0:4180
#OAUTH2_PROXY_ALLOWED_ROLES: <OPTIONAL>
KC_CONFIG_VOLUME: adiosdb_kc_config
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
- >
docker run -d -p $PORT_MAPPING --name $CONTAINER_NAME
--network $APP_NETWORK --restart unless-stopped
--env OAUTH2_PROXY_PROVIDER=$OAUTH2_PROXY_PROVIDER
--env OAUTH2_PROXY_CLIENT_ID=$OAUTH2_PROXY_CLIENT_ID
--env OAUTH2_PROXY_CLIENT_SECRET=$AUTH_SECRET
--env OAUTH2_PROXY_REDIRECT_URL=$OAUTH2_PROXY_REDIRECT_URL
--env OAUTH2_PROXY_OIDC_ISSUER_URL=$OAUTH2_PROXY_OIDC_ISSUER_URL
--env OAUTH2_PROXY_EMAIL_DOMAINS=$OAUTH2_PROXY_EMAIL_DOMAINS
--env OAUTH2_PROXY_COOKIE_SECRET=$OAUTH2_PROXY_COOKIE_SECRET
--env OAUTH2_PROXY_UPSTREAMS=$OAUTH2_PROXY_UPSTREAMS
--env OAUTH2_PROXY_COOKIE_DOMAIN=$OAUTH2_PROXY_COOKIE_DOMAIN
--env OAUTH2_PROXY_HTTP_ADDRESS=$OAUTH2_PROXY_HTTP_ADDRESS
--env OAUTH2_PROXY_INSECURE_OIDC_ALLOW_UNVERIFIED_EMAIL=true
--env OAUTH2_PROXY_CUSTOM_TEMPLATES_DIR=/data/kc_config
--env OAUTH2_PROXY_CUSTOM_SIGN_IN_LOGO=/data/kc_config/NOAA_logo.svg
-v $KC_CONFIG_VOLUME:/data/kc_config
$IMAGE_TAG
tags:
- adios-stage
- deploy
stop_oauth_api_stage:
stage: deploy
only:
- develop
when: manual
environment:
name: stage
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: auth_web_api
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-stage
- deploy
deploy_client_stage:
stage: deploy
only:
- develop
except:
- schedules
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
on_stop: stop_client_stage
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-client-dbg
CONTAINER_NAME: adios_db_web_client
APP_NETWORK: adios_net
PORT_MAPPING: 127.0.0.1:8083:4200
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
- >
docker run -d -p $PORT_MAPPING --name $CONTAINER_NAME
--network $APP_NETWORK
--restart unless-stopped $IMAGE_TAG
tags:
- adios-stage
- deploy
stop_client_stage:
stage: deploy
only:
- develop
when: manual
environment:
name: stage
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: adios_db_web_client
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-stage
- deploy
deploy_oauth_client_stage:
stage: deploy
only:
- develop
except:
- schedules
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
on_stop: stop_oauth_client_stage
variables:
IMAGE_TAG: registry.orr.noaa.gov/it/oauth2-proxy:master
CONTAINER_NAME: auth_web_client
APP_NETWORK: adios_net
PORT_MAPPING: 8003:4180
OAUTH2_PROXY_PROVIDER: keycloak-oidc
OAUTH2_PROXY_CLIENT_ID: adios-database
OAUTH2_PROXY_REDIRECT_URL: https://adios-stage.orr.noaa.gov/oauth2/callback
OAUTH2_PROXY_OIDC_ISSUER_URL: https://auth.orr.noaa.gov/auth/realms/ORR
OAUTH2_PROXY_EMAIL_DOMAINS: noaa.gov
OAUTH2_PROXY_COOKIE_SECRET: penguinsarereallythebest
OAUTH2_PROXY_UPSTREAMS: http://adios_db_web_client:4200
OAUTH2_PROXY_COOKIE_DOMAIN: https://adios-stage.orr.noaa.gov
OAUTH2_PROXY_HTTP_ADDRESS: 0.0.0.0:4180
#OAUTH2_PROXY_ALLOWED_ROLES: <OPTIONAL>
KC_CONFIG_VOLUME: adiosdb_kc_config
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
#- OAUTH2_PROXY_CLIENT_SECRET=`cat /data/adios_oil_db/oauth-proxy-client-secret.txt`
- >
docker run -d -p $PORT_MAPPING --name $CONTAINER_NAME
--network $APP_NETWORK --restart unless-stopped
--env OAUTH2_PROXY_PROVIDER=$OAUTH2_PROXY_PROVIDER
--env OAUTH2_PROXY_CLIENT_ID=$OAUTH2_PROXY_CLIENT_ID
--env OAUTH2_PROXY_CLIENT_SECRET=$AUTH_SECRET
--env OAUTH2_PROXY_REDIRECT_URL=$OAUTH2_PROXY_REDIRECT_URL
--env OAUTH2_PROXY_OIDC_ISSUER_URL=$OAUTH2_PROXY_OIDC_ISSUER_URL
--env OAUTH2_PROXY_EMAIL_DOMAINS=$OAUTH2_PROXY_EMAIL_DOMAINS
--env OAUTH2_PROXY_COOKIE_SECRET=$OAUTH2_PROXY_COOKIE_SECRET
--env OAUTH2_PROXY_UPSTREAMS=$OAUTH2_PROXY_UPSTREAMS
--env OAUTH2_PROXY_COOKIE_DOMAIN=$OAUTH2_PROXY_COOKIE_DOMAIN
--env OAUTH2_PROXY_HTTP_ADDRESS=$OAUTH2_PROXY_HTTP_ADDRESS
--env OAUTH2_PROXY_INSECURE_OIDC_ALLOW_UNVERIFIED_EMAIL=true
--env OAUTH2_PROXY_CUSTOM_TEMPLATES_DIR=/data/kc_config
--env OAUTH2_PROXY_CUSTOM_SIGN_IN_LOGO=/data/kc_config/NOAA_logo.svg
-v $KC_CONFIG_VOLUME:/data/kc_config
$IMAGE_TAG
tags:
- adios-stage
- deploy
stop_oauth_client_stage:
stage: deploy
only:
- develop
when: manual
environment:
name: stage
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: auth_web_client
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-stage
- deploy
deploy_api_public:
stage: deploy
only:
- production
environment:
name: public
url: https://adios.orr.noaa.gov
on_stop: stop_api_public
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-api
CONTAINER_NAME: adios_db_web_api
APP_NETWORK: adios_net
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
- >
docker run -d --name $CONTAINER_NAME --network $APP_NETWORK --restart unless-stopped
-e MONGODB_WRITEABLE=false $IMAGE_TAG
tags:
- adios-prod
- deploy
stop_api_public:
stage: deploy
only:
- production
when: manual
environment:
name: public
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: adios_db_web_api
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-prod
- deploy
deploy_client_public:
stage: deploy
only:
- production
environment:
name: public
url: https://adios.orr.noaa.gov
on_stop: stop_client_public
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:adios-db-web-client
CONTAINER_NAME: adios_db_web_client
APP_NETWORK: adios_net
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
- >
docker run -d --name $CONTAINER_NAME --network $APP_NETWORK --restart unless-stopped
$IMAGE_TAG
tags:
- adios-prod
- deploy
stop_client_public:
stage: deploy
only:
- production
when: manual
environment:
name: public
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: adios_db_web_client
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-prod
- deploy
deploy_proxy_public:
stage: deploy
only:
- production
environment:
name: public
url: https://adios.orr.noaa.gov
on_stop: stop_proxy_public
variables:
IMAGE_TAG: nginx
CONTAINER_NAME: adios_db_web_proxy
APP_NETWORK: adios_net
PORT_MAPPING1: 443:443
PORT_MAPPING2: 80:80
OILDB_PROJ_FOLDER: /data/adios_oil_db/oildb-deploy
GIT_STRATEGY: none
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- >
docker network inspect $APP_NETWORK >/dev/null 2>&1 ||
docker network create -d bridge $APP_NETWORK
- docker pull $IMAGE_TAG
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
- if [ -d $OILDB_PROJ_FOLDER ]; then rm -rf $OILDB_PROJ_FOLDER; fi
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oildb-deploy.git $OILDB_PROJ_FOLDER
- chmod go+rw $OILDB_PROJ_FOLDER/config/public/proxy/*
- >
chmod go+rx
$OILDB_PROJ_FOLDER
$OILDB_PROJ_FOLDER/config
$OILDB_PROJ_FOLDER/config/public
$OILDB_PROJ_FOLDER/config/public/proxy
- ls -la $OILDB_PROJ_FOLDER
- ls -la $OILDB_PROJ_FOLDER/config/public/proxy
- ls -la /etc/ssl/certs/*
- >
docker run -d --name $CONTAINER_NAME --network $APP_NETWORK --restart unless-stopped
-p $PORT_MAPPING1 -p $PORT_MAPPING2
-v $OILDB_PROJ_FOLDER/config/public/proxy:/etc/nginx/
-v /etc/ssl/certs:/etc/ssl/certs $IMAGE_TAG
tags:
- adios-prod
- deploy
stop_proxy_public:
stage: deploy
only:
- production
when: manual
environment:
name: public
action: stop
variables:
GIT_STRATEGY: none
CONTAINER_NAME: adios_db_web_proxy
script:
- docker stop $CONTAINER_NAME && docker container rm --volumes $CONTAINER_NAME
tags:
- adios-prod
- deploy
init_git_repo_on_stage:
stage: maintenance
image: registry.orr.noaa.gov/erd/centos-conda/ubuntu/ubuntuforge-python$PYTHON_VER
when: manual
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
variables:
CONTAINER_NAME: adios_db_web_api
SCRIPT_NAME: init_noaa_data.sh
script:
- docker cp ./web_api/$SCRIPT_NAME $CONTAINER_NAME:/
- docker cp ./web_api/git_functions.sh $CONTAINER_NAME:/
- docker exec $CONTAINER_NAME /bin/bash /$SCRIPT_NAME
tags:
- adios-stage
sync_with_git_review:
stage: maintenance
image: registry.orr.noaa.gov/erd/centos-conda/ubuntu/ubuntuforge-python$PYTHON_VER
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
tags:
- adios-stage
variables:
CONTAINER_NAME: adios_db_web_api
SCRIPT_NAME: sync_with_under_review.sh
script:
- docker cp ./web_api/$SCRIPT_NAME $CONTAINER_NAME:/
- docker cp ./web_api/git_functions.sh $CONTAINER_NAME:/
- docker exec $CONTAINER_NAME /bin/bash /$SCRIPT_NAME
sync_with_git_prod:
stage: maintenance
image: registry.orr.noaa.gov/erd/centos-conda/ubuntu/ubuntuforge-python$PYTHON_VER
when: manual
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
tags:
- adios-stage
variables:
CONTAINER_NAME: adios_db_web_api
SCRIPT_NAME: sync_with_production.sh
script:
- docker cp ./web_api/$SCRIPT_NAME $CONTAINER_NAME:/
- docker cp ./web_api/git_functions.sh $CONTAINER_NAME:/
- docker exec $CONTAINER_NAME /bin/bash /$SCRIPT_NAME
pull_remote_under_review_changes:
stage: maintenance
image: registry.orr.noaa.gov/erd/centos-conda/ubuntu/ubuntuforge-python$PYTHON_VER
when: manual
environment:
name: stage
url: https://adios-stage.orr.noaa.gov
tags:
- adios-stage
variables:
CONTAINER_NAME: adios_db_web_api
SCRIPT_NAME: pull_remote_under_review_changes.sh
script:
- docker cp ./web_api/$SCRIPT_NAME $CONTAINER_NAME:/
- docker cp ./web_api/git_functions.sh $CONTAINER_NAME:/
- docker exec $CONTAINER_NAME /bin/bash /$SCRIPT_NAME
drop_db_volume_public:
stage: maintenance
image: registry.orr.noaa.gov/erd/centos-conda/ubuntu/ubuntuforge-python$PYTHON_VER
when: manual
environment:
name: public
url: https://adios.orr.noaa.gov
tags:
- adios-prod
variables:
DB_VOLUME: dbdata
script:
- docker volume rm $DB_VOLUME