forked from webkom/lego-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.yml
354 lines (330 loc) · 8.04 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
---
kind: pipeline
type: docker
name: default
steps:
- name: postgres
image: postgres:9.5
detach: true
environment:
POSTGRES_USER: lego
POSTGRES_HOST_AUTH_METHOD: trust
when:
event: [push]
branch:
exclude: [ prod ]
- name: minio
image: minio/minio
detach: true
environment:
MINIO_ACCESS_KEY: lego-dev
MINIO_SECRET_KEY: lego-dev
commands:
- /usr/bin/docker-entrypoint.sh server /export
when:
event: [push]
branch:
exclude: [ prod ]
- name: thumbor
image: apsl/thumbor:latest
detach: true
environment:
SECURITY_KEY: 'lego-dev'
MAX_WIDTH: '1000'
MAX_HEIGHT: '800'
QUALITY: '98'
ALLOW_UNSAFE_URL: '0'
ALLOW_OLD_URLS: '0'
AWS_ACCESS_KEY_ID: 'lego-dev'
AWS_SECRET_ACCESS_KEY: 'lego-dev'
TC_AWS_LOADER_BUCKET: lego
TC_AWS_REGION: us-east-1
TC_AWS_ENDPOINT: '"http://minio:9000"'
LOADER: tc_aws.loaders.s3_loader
links:
- minio
when:
event: [push]
branch:
exclude: [ prod ]
- name: redis
image: redis
detach: true
when:
event: [push]
branch:
exclude: [ prod ]
- name: api
image: registry.webkom.dev/webkom/lego:latest
detach: true
pull: true
commands:
- ./wait-for-it.sh -t 60 postgres:5432
- ./wait-for-it.sh -t 60 redis:6379
- ./wait-for-it.sh -t 60 minio:9000
- ./wait-for-it.sh -t 60 thumbor:8000
- cd /app
- python manage.py reset_db --noinput
- python manage.py migrate
- python manage.py migrate_search
- python manage.py load_fixtures --development
- python manage.py rebuild_index
- python manage.py runserver 0.0.0.0:8000
environment:
PORT: '8000'
ALLOWED_HOSTS: '*,'
DATABASE_URL: 'postgres://lego@postgres:5432/lego'
SECRET_KEY: 'abc123'
SERVER_URL: 'http://api:8000'
FRONTEND_URL: 'http://ssr:3000'
CACHE_URL: 'rediscache://redis/0?client_class: django_redis.client.DefaultClient'
EMAIL_URL: 'smtp://localhost'
AWS_ACCESS_KEY_ID: 'lego-dev'
AWS_SECRET_ACCESS_KEY: 'lego-dev'
AWS_REGION: 'us-east-1'
AWS_S3_BUCKET: 'lego'
AWS_ENTRYPOINT: 'http://minio:9000'
THUMBOR_SERVER: 'http://thumbor:8000'
THUMBOR_SECURITY_KEY: 'lego-dev'
SENTRY: 'http://sentry:sentry@localhost/2'
CELERY_BROKER_URL: 'redis://redis/1'
CHANNELS_REDIS_URL: 'redis://redis/2'
ELASTICSEARCH_HOST: 'http://elasticsearch'
STRIPE_API_KEY: '123'
STRIPE_WEBHOOK_SECRET: '123'
CAPTCHA_KEY: '123'
LDAP_SERVER: 'localhost'
LDAP_USER: '123'
LDAP_PASSWORD: '123'
APNS_CERTIFICATE: '123'
SEARCH_BACKEND: 'postgres'
ELASTICSEARCH_HOST: 'ignored'
CORS_ORIGIN_DOMAINS: 'ssr:3000'
when:
event: [push]
branch:
exclude: [prod]
- name: legocypresshelper
image: abakus/lego-cypress-helper:latest
detach: true
pull: true
when:
event: [push]
branch:
exclude: [prod]
environment:
PG_HOST: postgres
PG_USERNAME: lego
PG_DATABASE: lego
commands:
- cd /app
- ./wait-for-it.sh -t 420 api:8000
- node index.js
- echo "server stopped"
- name: setup
image: node:11
when:
event: [push]
depends_on:
- postgres
- minio
- thumbor
- redis
- api
volumes:
- name: yarn_cache
path: /tmp/cache
environment:
CYPRESS_INSTALL_BINARY: 0
commands:
- yarn --frozen-lockfile --cache-folder /tmp/cache
- name: build_server
image: node:11
when:
event: [push]
branch:
exclude: [prod]
depends_on:
- setup
commands:
- yarn build:server
- name: build_client
image: node:11
when:
event: [push]
branch:
exclude: [prod]
depends_on:
- setup
commands:
- yarn build:client
- name: test
image: node:11
when:
event: [push]
depends_on:
- setup
commands:
- yarn test
- name: lint
image: node:11
when:
event: [push]
depends_on:
- setup
commands:
- yarn lint
- name: flow
image: node:11
when:
event: [push]
depends_on:
- setup
commands:
- yarn flow --quiet
- name: install_cypress
image: node:11
when:
event: [push]
branch:
exclude: [prod]
depends_on:
- setup
environment:
CYPRESS_CACHE_FOLDER: /drone/src/.cypress_cache
commands:
- yarn cypress install
- name: ssr
image: node:11
detach: true
when:
event: [push]
branch:
exclude: [prod]
depends_on:
- build_client
- build_server
environment:
API_URL: http://api:8000/api/v1
BASE_URL: http://api:8000
WS_URL: ws://api:8000
ENVIRONMENT: ci
commands:
- yarn ssr
- name: cypress
image: cypress/browsers:chrome69
shm_size: 100000000 # 100MB
when:
event: [push]
branch:
exclude: [prod]
depends_on:
- legocypresshelper
- install_cypress
- ssr
environment:
CYPRESS_API_BASE_URL: http://api:8000
CYPRESS_RESET_DB_API: http://legocypresshelper:3030
CYPRESS_BASE_URL: http://ssr:3000
CYPRESS_CACHE_FOLDER: /drone/src/.cypress_cache
CYPRESS_RECORD_KEY:
from_secret: cypress_record_key
commands:
- ./wait-for-it.sh -t 180 ssr:3000
- ./wait-for-it.sh -t 180 legocypresshelper:3030
- yarn cypress run --record
- name: docker
image: plugins/docker
when:
branch:
- prod
event: push
status: success
depends_on:
- build_server
- build_client
- test
- lint
- flow
- ssr
- cypress
environment:
SENTRY_AUTH_TOKEN:
from_secret: sentry_auth_token
settings:
registry: https://registry.webkom.dev
repo: registry.webkom.dev/webkom/lego-webapp
username:
from_secret: docker_username
password:
from_secret: docker_password
tags:
- ${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:7}
- latest
build_args:
- RELEASE=${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:7}
- COMMIT_SHA=${DRONE_COMMIT_SHA}
- SENTRY_ORG=abakus
- SENTRY_PROJECT=lego-webapp
- SENTRY_URL=https://sentry.io/
build_args_from_env:
- SENTRY_AUTH_TOKEN
- name: clone_infra
image: alpine/git
volumes:
- name: infrastructure
path: /infrastructure
environment:
INFRA_SSH_KEY:
from_secret: infra_deploy_key
commands:
# These commands configure our authentication against
# github so we can clone our infra repo
- mkdir -p /root/.ssh
- echo -n "$INFRA_SSH_KEY" > /root/.ssh/id_rsa
- chmod 600 /root/.ssh/id_rsa
- touch /root/.ssh/known_hosts
- chmod 600 /root/.ssh/known_hosts
- ssh-keyscan -t rsa -H github.com > /etc/ssh/ssh_known_hosts 2> /dev/null
- git clone [email protected]:webkom/infrastructure.git /infrastructure
when:
event:
- promote
- rollback
branch:
- prod
- name: Deploy
image: plugins/ansible
volumes:
- name: infrastructure
path: /infrastructure
settings:
playbook: /infrastructure/lego/playbooks/deploy.yml
tags:
- webapp
# This is the same tag as the docker step above
extra_vars: webapp_version=${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:7}
inventory: /infrastructure/lego/${DRONE_DEPLOY_TO}
vault_password:
from_secret: ansible_vault_password
private_key:
from_secret: infra_deploy_key
when:
event:
- promote
- rollback
branch:
- prod
depends_on:
- clone_infra
volumes:
- name: yarn_cache
host:
path: /tmp/drone-cache/yarn
- name: infrastructure
temp: {}
image_pull_secrets:
- dockerconfigjson
---
kind: signature
hmac: 0cfd195dbd86de598289a8ec09d336b20792889eb7095c4e78a42b5ef789732d