-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yaml
218 lines (201 loc) · 4.96 KB
/
docker-compose.yaml
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
version: "3.9"
# LOCAL DEV
services:
api:
container_name: api
user: 1000:1000
build:
context: app/api/
dockerfile: Dockerfile.dev
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
ports:
- 5000:5000
command: uvicorn api.main.app:api --reload --host=0.0.0.0 --port=5000 --log-config=api/logger_config.yaml
volumes:
# Mount local codebase to reflect changes for local dev
- ./app/api:/app/api
healthcheck:
test: ["CMD", "curl", "localhost:5000/api/health"]
interval: 5s
timeout: 5s
retries: 5
depends_on:
- migs
- migssanctuary
- testapi
- seeder
migs:
container_name: migs
build:
context: app/api/
dockerfile: Dockerfile.dev
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
command: bash -c "cd /app/api && alembic --name=medical upgrade head"
volumes:
# Mount local codebase to reflect changes for local dev
- ./app/api:/app/api
depends_on:
db:
condition: service_healthy
migssanctuary:
container_name: migssanctuary
build:
context: app/api/
dockerfile: Dockerfile.dev
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
command: bash -c "cd /app/api && alembic --name=sanctuary upgrade head"
volumes:
# Mount local codebase to reflect changes for local dev
- ./app/api:/app/api
depends_on:
db:
condition: service_healthy
db:
container_name: db
user: postgres
image: postgres:13.2-alpine
restart: always
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
ports:
- 5432:5432
healthcheck:
test: ["CMD", "pg_isready"]
interval: 5s
timeout: 5s
retries: 5
volumes:
- ./scripts/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
testapi:
container_name: testapi
user: 1000:1000
build:
context: app/api/
dockerfile: Dockerfile.dev
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
- IS_TEST=test
# run as module so basedir (root) is added to python path
command: python -m pytest api/tests/
volumes:
- ./app/api/:/app/api
depends_on:
- migs
seeder:
container_name: seeder
user: 1000:1000
build:
context: app/api/
dockerfile: seeder/Dockerfile.seed
env_file: app/api/.env
tty: true
environment:
- POSTGRES_HOST=db
volumes:
- ./app/api/:/app/api
command: python -m api.seeder.seed_database
depends_on:
- testapi
web:
container_name: web
user: node
build:
context: app/web/
dockerfile: Dockerfile.dev
volumes:
- ./app/web:/code
ports:
- 3000:3000
depends_on:
- api
# Used for deploying artifacts or data to Google Cloud
webprod:
container_name: webprod
user: node
command: yarn build && tail -f /dev/null
build:
context: app/web/
dockerfile: Dockerfile.dev
volumes:
- ./app/web/contexts:/code/contexts
- ./app/web/pages:/code/pages
- ./app/web/public:/code/public
- ./app/web/styles:/code/styles
- ./app/web/utils:/code/utils
migsprod:
container_name: migsprod
build:
context: app/api/
dockerfile: .Dockerfile.prod
env_file: app/api/.env
volumes:
# Mount local codebase to reflect changes for local dev
- ./app/api:/app/api
command: bash -c "cd /app/api && alembic --name=medical upgrade head"
#PRODUCTION IMAGE VERIFICATION
apitarget:
container_name: apitarget
user: 1000:1000
build:
context: app/api/
dockerfile: Dockerfile.prod
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
ports:
- 5000:5000
command: uvicorn api.main.app:api --reload --host=0.0.0.0 --port=5000 --log-config=api/logger_config.yaml
healthcheck:
test: ["CMD", "curl", "localhost:5000/api/health"]
interval: 5s
timeout: 5s
retries: 5
depends_on:
- migstarget
- testapitarget
migstarget:
container_name: migstarget
build:
context: app/api
dockerfile: Dockerfile.prod
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
command: bash -c "cd /app/api && alembic -name=medical upgrade head && alembic -name=sanctuary upgrade head"
depends_on:
db:
condition: service_healthy
testapitarget:
container_name: testapitarget
user: 1000:1000
build:
context: app/api
dockerfile: Dockerfile.prod
env_file: app/api/.env
environment:
- POSTGRES_HOST=db
#run as module so basedir (root) is added to python path
command: python -m pytest api/tests/
depends_on:
- migstarget
webtarget:
container_name: webtarget
user: node
build:
context: app/web/
dockerfile: Dockerfile.prod
ports:
- 3000:3000
depends_on:
- apitarget
networks:
default:
driver: "bridge"