-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
295 lines (288 loc) · 8.06 KB
/
docker-compose.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
x-service-node-webapp-production-base: &node-webapp-production-base
build: &node-webapp-production-base-build
args:
GIT_SHORT_SHA:
context: .
dockerfile: Dockerfile.d/node-webapp.production/Dockerfile
target: base
# https://docs.docker.com/compose/compose-file/compose-file-v3/#build
# > If you specify image as well as build, then Compose names the built image with the webapp and optional tag specified in image:
image: local.local/${PROJECT_UNIQUE_ID:-no-name}/base-prod:HEAD
init: false # because tiny is specified as the entrypoint on the Dockerfile
pull_policy: never
x-service-node-webapp-development-base: &node-webapp-development-base
build: &node-webapp-development-base-build
args:
GID: ${GID:-0}
UID: ${UID:-0}
context: Dockerfile.d/node-webapp.development
target: default
command:
- zsh
- --login
- -c
- |
npm-check-updates --upgrade
npm install
npm audit fix
sort-package-json
sleep infinity
image: local.local/${PROJECT_UNIQUE_ID:-no-name}/default-dev:HEAD
init: true
pull_policy: never
user: ${UID:-0}:${GID:-0}
volumes:
- home-developer:/home/developer
- home-root:/root # for macOS & Windows
- .:/workspace
working_dir: /workspace
x-service-bff-base: &bff-base
<<: *node-webapp-development-base
depends_on:
mysql:
condition: service_started
redis:
condition: service_started
environment:
DATABASE_URL: mysql://root@mysql:3306/app_dev
working_dir: /workspace/bff
x-service-frontend-base: &frontend-base
<<: *node-webapp-development-base
environment:
FRONTEND_BFF_ENDPOINT_GRAPHQL_HTTP: http://${PUBLIC_IP_ADDR_OR_FQDN:-bff}:4000/graphql
FRONTEND_BFF_ENDPOINT_GRAPHQL_WEBSOCKET: ws://${PUBLIC_IP_ADDR_OR_FQDN:-bff}:4000/graphql
FRONTEND_BFF_ENDPOINT_OPENAPI: http://${PUBLIC_IP_ADDR_OR_FQDN:-bff}:4000
working_dir: /workspace/frontend
services:
bff:
<<: *bff-base
command:
- zsh
- --login
- -c
- |
npm-check-updates --upgrade
npm install
npm audit fix
sort-package-json
/workspace/scripts/wait-redis.bash redis
/workspace/scripts/wait-mysql.bash mysql
npx prisma migrate status || {
echo 'The DB migration is needed.'
}
npm run db:migrate:dev
npm run start:dev
healthcheck:
test:
- CMD
- curl
- --fail
- --output
- /dev/null
- --silent
- localhost:4000/openapi/status
interval: 8s
timeout: 1s
retries: 64
start_period: 16s
ports:
- ${BIND_IP_ADDR:-127.0.0.1}:4000:4000
- ${BIND_IP_ADDR:-127.0.0.1}:49229:9229
bff-test-watch:
<<: *bff-base
command:
- zsh
- --login
- -c
- |
npm run test:watch
depends_on:
bff:
condition: service_healthy
profiles:
- all
- dev-all
bff-prod:
<<: *node-webapp-production-base
build:
<<: *node-webapp-production-base-build
target: bff-runner
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
environment:
DATABASE_URL: ${DATABASE_URL:-mysql://root@mysql:3306/app_rc}
image: local.local/${PROJECT_UNIQUE_ID:-no-name}/bff-prod:HEAD
ports:
- ${BIND_IP_ADDR:-127.0.0.1}:14000:4000
profiles:
- all
- prod
e2e-tests:
<<: *node-webapp-development-base
build:
<<: *node-webapp-development-base-build
target: e2e-tests
command:
- zsh
- --login
- -c
- |
npm-check-updates --upgrade
npm install
npm audit fix
npm run playwright:install
sort-package-json
sleep infinity
environment:
BFF_URL: http://${PUBLIC_IP_ADDR_OR_FQDN:-bff}:4000
E2E_TARGET_NODE_ENV: development
FRONTEND_URL: http://${PUBLIC_IP_ADDR_OR_FQDN:-frontend}:3000
image: local.local/${PROJECT_UNIQUE_ID:-no-name}/e2e-tests-dev:HEAD
ports:
# https://github.com/microsoft/playwright/pull/18517
- ${BIND_IP_ADDR:-127.0.0.1}:9323:9323
profiles:
- all
- dev-all
working_dir: /workspace/e2e-tests
frontend:
<<: *frontend-base
command:
- zsh
- --login
- -c
- |
npm-check-updates --upgrade --reject graphql-codegen-plugin-typescript-swr,openapi2aspida
npm install
npm audit fix
sort-package-json
npm run dev:debug
healthcheck:
test:
- CMD
- curl
- --fail
- --output
- /dev/null
- --silent
- localhost:3000/api/status
interval: 8s
timeout: 1s
retries: 64
start_period: 16s
ports:
- ${BIND_IP_ADDR:-127.0.0.1}:3000:3000
- ${BIND_IP_ADDR:-127.0.0.1}:39229:9229
frontend-prod:
<<: *node-webapp-production-base
build:
<<: *node-webapp-production-base-build
target: frontend-runner
environment:
FRONTEND_BFF_ENDPOINT_GRAPHQL_HTTP: http://bff-prod:4000/graphql
FRONTEND_BFF_ENDPOINT_OPENAPI: http://bff-prod:4000
image: local.local/${PROJECT_UNIQUE_ID:-no-name}/frontend-prod:HEAD
ports:
- ${BIND_IP_ADDR:-127.0.0.1}:13000:3000
profiles:
- all
- prod
frontend-storybook:
<<: *frontend-base
command:
- zsh
- --login
- -c
- |
npm run storybook
depends_on:
frontend:
condition: service_healthy
ports:
- ${BIND_IP_ADDR:-127.0.0.1}:6006:6006
profiles:
- all
- dev-all
frontend-test-watch:
<<: *frontend-base
command:
- zsh
- --login
- -c
- |
npm run test:watch
depends_on:
frontend:
condition: service_healthy
profiles:
- all
- dev-all
# Middlewares
mysql:
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
healthcheck:
test:
- CMD
- mysql
- --host=mysql
- --user=root
- --execute=quit
interval: 8s
timeout: 1s
retries: 8
start_period: 4s
# https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/MySQL.Concepts.VersionMgmt.html
# https://learn.microsoft.com/en-us/azure/mysql/concepts-version-policy#supported-mysql-versions
# https://cloud.google.com/sql/docs/mysql/db-versions
image: mysql:8
init: true
ports:
- ${BIND_IP_ADDR:-127.0.0.1}:3306:3306
volumes:
- .:/workspace
# https://hub.docker.com/_/mysql
# > Initializing a fresh instance
# > When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables.
# > Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d.
- ./mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro
- mysql-data:/var/lib/mysql
redis:
# https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/supported-engine-versions.html
# https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-overview#redis-versions
# https://cloud.google.com/memorystore/docs/redis/supported-versions#current_versions
image: redis:6
init: true
healthcheck:
test:
- CMD
- redis-cli
- ping
interval: 8s
timeout: 1s
retries: 8
start_period: 2s
ports:
- ${BIND_IP_ADDR:-127.0.0.1}:6379:6379
volumes:
- .:/workspace
# for Prettier Code Formatter
# ["INFO" - 00:00:00 AM] Attempted to determine module path from /path/to/the/project
# ["ERROR" - 00:00:00 AM] Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`
# ["ERROR" - 00:00:00 AM] Cannot find module 'prettier' from '/path/to/the/project'
workspace:
<<: *node-webapp-development-base
version: '3.9'
volumes:
home-developer:
driver: local
home-root:
driver: local
mysql-data:
driver: local