forked from webkom/lego-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.drone.yml
367 lines (343 loc) · 8.02 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
---
kind: pipeline
type: docker
name: default
trigger:
event:
exclude:
- pull_request
steps:
- name: postgres
image: postgres:12.3
detach: true
environment:
POSTGRES_USER: lego
POSTGRES_HOST_AUTH_METHOD: trust
when:
event: [push]
branch:
exclude: [build]
- 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: [build]
- 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: [build]
- name: redis
image: redis
detach: true
when:
event: [push]
branch:
exclude: [build]
- 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'
OAUTH_CACHE: 'redis://redis/9'
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'
STRIPE_API_KEY: '123'
STRIPE_WEBHOOK_SECRET: '123'
CAPTCHA_KEY: '123'
PLAUSIBLE_KEY: 'lego-dev'
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: [build]
- name: legocypresshelper
image: abakus/lego-cypress-helper:latest
detach: true
pull: true
when:
event: [push]
branch:
exclude: [build]
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:16-alpine
when:
event: [push]
branch:
exclude: [build]
depends_on:
- postgres
- minio
- thumbor
- redis
- api
volumes:
- name: yarn_cache
path: /tmp/cache
environment:
CYPRESS_INSTALL_BINARY: 0
commands:
- apk --no-cache add curl
- yarn --frozen-lockfile --cache-folder /tmp/cache
- name: build_packages
image: node:16-alpine
when:
event: [push]
branch:
exclude: [build]
depends_on:
- setup
commands:
- yarn build:packages
- name: build_server
image: node:16-alpine
when:
event: [push]
branch:
exclude: [build]
depends_on:
- setup
- build_packages
commands:
- yarn build:server
- name: build_client
image: node:16-alpine
when:
event: [push]
branch:
exclude: [build]
depends_on:
- setup
- build_packages
commands:
- yarn build:client
- name: test
image: node:16-alpine
when:
event: [push]
branch:
exclude: [build]
depends_on:
- setup
commands:
- yarn test
- yarn test:packages
- name: lint
image: node:16-alpine
when:
event: [push]
branch:
exclude: [build]
depends_on:
- setup
commands:
- yarn lint
- yarn lint:packages
- name: typescript
image: node:16-slim
when:
event: [push]
branch:
exclude: [build]
depends_on:
- setup
commands:
- yarn types
failure: ignore
- name: typescript_packages
image: node:16-slim
when:
event: [ push ]
branch:
exclude: [ build ]
depends_on:
- setup
commands:
- yarn types:packages
- name: install_cypress
image: node:16-alpine
when:
event: [push]
branch:
exclude: [build]
depends_on:
- setup
environment:
CYPRESS_CACHE_FOLDER: /drone/src/.cypress_cache
commands:
- yarn cypress install
- name: ssr
image: node:16-alpine
detach: true
when:
event: [push]
branch:
exclude: [build]
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:node16.18.0-chrome107-ff106-edge
shm_size: 512m
ipc: host
when:
event: [push]
branch:
exclude: [build]
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:
- build
event: push
status: success
depends_on:
- build_server
- build_client
- test
- lint
- typescript
- 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:
- version-${DRONE_COMMIT_SHA:0:7}
- latest
build_args:
- RELEASE=version-${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: Deploy
image: abakus/ansible-deploy
settings:
playbook: /infrastructure/lego/playbooks/deploy.yml
repository:
from_secret: infra_repository
tags:
- webapp
- ci
limit: ${DRONE_DEPLOY_TO}
extra_vars: webapp_version=version-${DRONE_COMMIT_SHA:0:7}
inventory: /infrastructure/inventory
vault_password:
from_secret: ansible_vault_password
private_key:
from_secret: infra_deploy_key
when:
event:
- promote
- rollback
branch:
- build
volumes:
- name: yarn_cache
host:
path: /tmp/drone-cache/yarn
image_pull_secrets:
- dockerconfigjson
---
kind: signature
hmac: 51b0a49b62c375f26f0ab24b0559fdf8f1747586051b25ffac639395f55b10d6
...