-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathdocker-compose.yml
210 lines (209 loc) · 4.95 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
name: funnel
x-postgres: &postgres
image: postgres:latest
restart: always
user: postgres
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
- POSTGRES_USER=postgres
expose:
- 5432
healthcheck:
interval: 5s
timeout: 5s
retries: 5
x-redis: &redis
image: redis:latest
expose:
- 6379
restart: always
healthcheck:
test: ['CMD', 'redis-cli', '--raw', 'incr', 'ping']
x-app: &app
extends:
file: docker/compose/services.yml
service: funnel-prod
build:
context: .
target: production
image: funnel
profiles:
- production
depends_on:
- redis
environment:
- REDIS_HOST=redis
x-test: &test-app
extends:
file: docker/compose/services.yml
service: funnel
image: funnel-test
profiles:
- test
build:
context: .
dockerfile: ci.Dockerfile
working_dir: /home/pn/app
user: pn
volumes:
- ./.cache/.npm:/home/pn/.npm
- ./.cache/node_modules:/home/pn/app/node_modules
- ./.cache/pip:/home/pn/.cache/pip
- ./.cache/.local:/home/pn/.local
- ./coverage:/home/pn/app/coverage
restart: 'no'
services:
app:
<<: *app
volumes:
- ./instance/settings.py:/home/pn/app/instance/settings.py
- ./docker/uwsgi/funnel.ini:/home/pn/funnel.ini:ro
command: ../funnel.ini
expose:
- 6400
ports:
- 6400:6400
pre-test:
<<: *test-app
user: root
entrypoint: ['/home/pn/app/docker/entrypoints/ci-pre-test.sh']
test:
<<: *test-app
depends_on:
pre-test:
condition: service_completed_successfully
redis-test:
condition: service_healthy
db-test:
condition: service_healthy
links:
- db-test
- redis-test
environment:
- REDIS_HOST=redis-test
- DB_HOST=db-test
- FLASK_SQLALCHEMY_DATABASE_URI=postgresql+psycopg://funnel@db-test/funnel_testing
- FLASK_SQLALCHEMY_BINDS__geoname=postgresql+psycopg://funnel@db-test/geoname_testing
db-test:
<<: *postgres
profiles:
- test
volumes:
- postgres_test:/var/lib/postgresql/data
- ./docker/initdb/test.sh:/docker-entrypoint-initdb.d/test.sh:ro
healthcheck:
test: ['CMD-SHELL', 'psql funnel_testing']
redis-test:
<<: *redis
profiles:
- test
volumes:
- redis_test:/data
dev:
extends:
file: docker/compose/services.yml
service: funnel
image: funnel-dev
container_name: funnel-dev
profiles:
- dev
- dev-no-watch
build:
context: .
target: dev
depends_on:
redis-dev:
condition: service_healthy
db-dev:
condition: service_healthy
working_dir: /home/pn/app
entrypoint: /home/pn/dev-entrypoint.sh
ports:
- 3000:3000
links:
- db-dev
- redis-dev
volumes:
# https://stackoverflow.com/questions/43844639/how-do-i-add-cached-or-delegated-into-a-docker-compose-yml-volumes-list
# https://forums.docker.com/t/what-happened-to-delegated-cached-ro-and-other-flags/105097/2
- pip_cache:/home/pn/.cache/pip:delegated
- .:/home/pn/app
- node_modules:/home/pn/app/node_modules
- ./docker/entrypoints/dev.sh:/home/pn/dev-entrypoint.sh:ro
- ./instance/settings.py:/home/pn/app/instance/settings.py
environment:
- DB_HOST=db-dev
- POSTGRES_USER_HOST=funnel@db-dev
- REDIS_HOST=redis-dev
healthcheck:
test: bash -c '[[ "$$(curl -o /dev/null -s -w "%{http_code}\n" http://funnel.test:3000)" == "200" ]]'
interval: 30s
timeout: 1m
retries: 10
start_period: 30s
asset-watcher:
extends:
file: docker/compose/services.yml
service: funnel
image: funnel-dev-asset-watcher
container_name: funnel-dev-asset-watcher
profiles:
- dev
build:
context: .
target: dev-assets
working_dir: /home/pn/app
entrypoint: npx webpack --mode development --watch
volumes:
- .:/home/pn/app
- node_modules:/home/pn/app/node_modules
environment:
- NODE_ENV=development
depends_on:
dev:
condition: service_healthy
healthcheck:
test: bash -c "[[ -f /home/pn/app/funnel/static/build/manifest.json ]]"
interval: 10s
timeout: 30s
retries: 60
start_period: 1m
db-dev:
<<: *postgres
profiles:
- dev
- dev-no-watch
volumes:
- postgres_dev:/var/lib/postgresql/data
- ./docker/initdb/dev.sh:/docker-entrypoint-initdb.d/dev.sh:ro
healthcheck:
test: ['CMD-SHELL', 'psql funnel']
redis-dev:
<<: *redis
profiles:
- dev
- dev-no-watch
volumes:
- redis_dev:/data
redis:
<<: *redis
profiles:
- production
volumes:
- redis:/data
x-tmpfs: &tmpfs
driver: local
driver_opts:
type: tmpfs
device: tmpfs
o: 'uid=999,gid=999' # uid:gid is 999:999 for both postgres and redis
volumes:
node_modules:
pip_cache:
postgres_dev:
redis_dev:
redis:
postgres_test:
<<: *tmpfs
redis_test:
<<: *tmpfs