-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcodefresh.yml
More file actions
211 lines (197 loc) · 7.04 KB
/
codefresh.yml
File metadata and controls
211 lines (197 loc) · 7.04 KB
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
version: '1.0'
mode: sequential
stages:
- build
- test
- push
- deploy
- run_jobs
steps:
build_images:
type: parallel
stage: 'build'
steps:
build_backend:
type: build
image_name: unicef/unpp-backend
dockerfile: Dockerfile
working_directory: ${{main_clone}}/backend
tag: ${{CF_BRANCH}}
build_arguments:
- env=${{ENV}}
- GIT_VERSION=${{CF_REVISION}}
build_frontend:
type: build
image_name: unicef/unpp-frontend
dockerfile: Dockerfile
working_directory: ${{main_clone}}/frontend
tag: ${{CF_BRANCH}}
build_proxy:
type: build
image_name: unicef/unpp-proxy
dockerfile: Dockerfile
working_directory: ${{main_clone}}/proxy
tag: ${{CF_BRANCH}}
backend_tests:
stage: 'test'
type: composition
composition: 'unicef-unpp'
when:
condition:
all:
noSkipTestInCommitMessage: 'includes(lower("${{CF_COMMIT_MESSAGE}}"), "skip tests") == false'
composition_candidates:
test:
image: ${{build_backend}}
depends_on:
- backend
command: 'bash -c "/usr/local/bin/wait-for-it.sh backend:8000 -t 240 && python /code/manage.py test --parallel && flake8 /code/backend"'
environment:
- ENV=dev
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=
- POSTGRES_HOST=db
- SECRET_KEY=asdfqwef124rf
- DJANGO_ALLOWED_HOST="*"
- FRONTEND_SERVICE_HOST=frontend
- UNHCR_API_HOST=https://api.test/
- UNHCR_API_USERNAME=user
- UNHCR_API_PASSWORD=password
- UNICEF_PARTNER_DETAILS_URL=https://api.test/
- UNICEF_API_USERNAME=user
- UNICEF_API_PASSWORD=password
push_images:
type: parallel
stage: 'push'
when:
branch:
only:
- develop
- master
steps:
push_backend_to_hub:
type: push
title: Pushing backend image to docker hub
registry: unicef-dockerhub
candidate: ${{build_backend}}
tags:
- ${{CF_BRANCH}}
- ${{CF_SHORT_REVISION}}
- latest
push_frontend_to_hub:
type: push
title: Pushing frontend image to docker hub
registry: unicef-dockerhub
candidate: ${{build_frontend}}
tags:
- ${{CF_BRANCH}}
- ${{CF_SHORT_REVISION}}
- latest
push_proxy_to_hub:
type: push
title: Pushing proxy image to docker hub
candidate: ${{build_proxy}}
registry: unicef-dockerhub
tags:
- ${{CF_BRANCH}}
- ${{CF_SHORT_REVISION}}
- latest
deploy_services:
type: parallel
stage: 'deploy'
when:
branch:
only:
- develop
- master
steps:
deploy_redis:
title: Deploying Redis
image: codefresh/cf-deploy-kubernetes
tag: latest
working_directory: ${{main_clone}}
commands:
- /cf-deploy-kubernetes ./kubernetes/redis/deployment.yml
environment:
- KUBECONTEXT=${{KUBECONTEXT}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
- KUBERNETES_DEPLOYMENT_TIMEOUT=500
deploy_backend:
title: Deploying backend
image: codefresh/cf-deploy-kubernetes
tag: latest
working_directory: ${{main_clone}}
commands:
- /cf-deploy-kubernetes ./kubernetes/backend/deployment.yml
environment:
- KUBECONTEXT=${{KUBECONTEXT}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
- ENV=${{ENV}}
- DJANGO_ALLOWED_HOST=${{DJANGO_ALLOWED_HOST}}
- POSTGRES_USER=${{POSTGRES_USER}}
- POSTGRES_DB=${{POSTGRES_DB}}
- POSTGRES_HOST=${{POSTGRES_HOST}}
- KUBERNETES_DEPLOYMENT_TIMEOUT=500
deploy_frontend:
title: Deploying frontend
image: codefresh/cf-deploy-kubernetes
tag: latest
working_directory: ${{main_clone}}
commands:
- /cf-deploy-kubernetes ./kubernetes/frontend/deployment.yml
environment:
- KUBECONTEXT=${{KUBECONTEXT}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
- ENV=${{ENV}}
- KUBERNETES_DEPLOYMENT_TIMEOUT=500
deploy_proxy:
title: Deploying nginx proxy
image: codefresh/cf-deploy-kubernetes
tag: latest
working_directory: ${{main_clone}}
commands:
- /cf-deploy-kubernetes ./kubernetes/proxy/deployment.yml
environment:
- KUBECONTEXT=${{KUBECONTEXT}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
- ENV=${{ENV}}
- KUBERNETES_DEPLOYMENT_TIMEOUT=500
delete_jobs:
stage: 'run_jobs'
title: Delete jobs with label redeploy
image: codefresh/kube-helm:master
environment:
- KUBECONTEXT=${{KUBECONTEXT}}
- NAMESPACE=${{NAMESPACE}}
commands:
- kubectl config get-contexts
- kubectl config use-context ${{KUBECONTEXT}}
- >-
kubectl --namespace ${{NAMESPACE}} delete job -lredeploy=true
when:
branch:
only:
- develop
- master
backend_jobs:
stage: 'run_jobs'
title: Creating backend jobs
image: codefresh/cf-deploy-kubernetes
tag: ${{CF_SHORT_REVISION}}
working_directory: ${{main_clone}}
commands:
- /cf-deploy-kubernetes ./kubernetes/backend/jobs.yml
environment:
- KUBECONTEXT=${{KUBECONTEXT}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
- ENV=${{ENV}}
- DJANGO_ALLOWED_HOST=${{DJANGO_ALLOWED_HOST}}
- POSTGRES_USER=${{POSTGRES_USER}}
- POSTGRES_DB=${{POSTGRES_DB}}
- POSTGRES_HOST=${{POSTGRES_HOST}}
when:
branch:
only:
- develop
- master