This repository has been archived by the owner on Apr 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
109 lines (104 loc) · 3.64 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
stages:
- build
- test
- deploy
build_qa:
image: docker:latest
services:
- docker:dind
tags:
- meedan
- meedan-labs
stage: build
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
script:
- apk add --no-cache curl jq python py-pip git
- pip install docutils==0.14
- pip install awscli==1.16.201
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -f docker/Dockerfile.production -t "$QA_ECR_API_BASE_URL:$CI_COMMIT_SHA" .
- docker push "$QA_ECR_API_BASE_URL:$CI_COMMIT_SHA"
- docker build -f docker/Dockerfile.production -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
test:
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
services:
- postgres:9.6
variables:
DB_NAME: vframe
DB_USER: postgres
DB_PASS: postgres
DB_HOST: postgres
tags:
- meedan
- meedan-labs
stage: test
script:
- . /opt/conda/etc/profile.d/conda.sh
- conda activate vframe
- git clone https://${GITHUB_TOKEN}:x-oauth-basic@github.com/meedan/configurator ./configurator
- source configurator/check/test/vframe/.env_file
- cd api && FLASK_ENV=test DB_NAME=vframe_test coverage run manage.py test
deploy_qa:
image: python:3-alpine
stage: deploy
tags:
- meedan
- meedan-labs
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
script:
- apk add --no-cache curl jq python py-pip git
- pip install ecs-deploy==1.7.0
- git clone https://${GITHUB_TOKEN}:x-oauth-basic@github.com/meedan/configurator ./configurator
- source configurator/check/qa/vframe/.env_file
- ecs deploy ecs-qa qa-vframe --image qa-vframe-c $QA_ECR_API_BASE_URL:$CI_COMMIT_SHA -e qa-vframe-c DB_USER $DB_USER -e qa-vframe-c DB_PASS $DB_PASS -e qa-vframe-c DB_HOST $DB_HOST -e qa-vframe-c DB_NAME $DB_NAME --timeout 3600
- echo "new Image was deployed $QA_ECR_API_BASE_URL:$CI_COMMIT_SHA"
only:
- develop
build_live:
image: docker:latest
services:
- docker:dind
tags:
- meedan
- meedan-labs
stage: build
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
script:
- apk add --no-cache curl jq python py-pip git
- pip install docutils==0.14
- pip install awscli==1.16.201
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -f docker/Dockerfile.production -t "$LIVE_ECR_API_BASE_URL:$CI_COMMIT_SHA" .
- docker push "$LIVE_ECR_API_BASE_URL:$CI_COMMIT_SHA"
only:
- master
deploy_live:
image: python:3-alpine
stage: deploy
when: manual
tags:
- meedan
- meedan-labs
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
script:
- apk add --no-cache curl jq python py-pip git
- pip install ecs-deploy==1.7.0
- git clone https://${GITHUB_TOKEN}:x-oauth-basic@github.com/meedan/configurator ./configurator
- source configurator/check/live/vframe/.env_file
- ecs deploy ecs-live live-vframe --image live-vframe-c $LIVE_ECR_API_BASE_URL:$CI_COMMIT_SHA -e live-vframe-c DB_USER $DB_USER -e live-vframe-c DB_PASS $DB_PASS -e live-vframe-c DB_HOST $DB_HOST -e live-vframe-c DB_NAME $DB_NAME --timeout 3600
- echo "new Image was deployed $LIVE_ECR_API_BASE_URL:$CI_COMMIT_SHA"
only:
- master