11version : " 3.4"
22x-restart-policy : &restart_policy
33 restart : unless-stopped
4+ x-depends_on-healthy : &depends_on-healthy
5+ condition : service_healthy
6+ x-depends_on-default : &depends_on-default
7+ condition : service_started
48x-healthcheck-defaults : &healthcheck_defaults
59 # Avoid setting the interval too small, as docker uses much more CPU than one would expect.
610 # Related issues:
@@ -15,20 +19,34 @@ x-sentry-defaults: &sentry_defaults
1519 << : *restart_policy
1620 image : " $SENTRY_IMAGE"
1721 depends_on :
18- - redis
19- - postgres
20- - memcached
21- - smtp
22- - snuba-api
23- - snuba-consumer
24- - snuba-outcomes-consumer
25- - snuba-sessions-consumer
26- - snuba-transactions-consumer
27- - snuba-subscription-consumer-events
28- - snuba-subscription-consumer-transactions
29- - snuba-replacer
30- - symbolicator
31- - kafka
22+ redis :
23+ << : *depends_on-healthy
24+ kafka :
25+ << : *depends_on-healthy
26+ postgres :
27+ << : *depends_on-healthy
28+ memcached :
29+ << : *depends_on-default
30+ smtp :
31+ << : *depends_on-default
32+ snuba-api :
33+ << : *depends_on-default
34+ snuba-consumer :
35+ << : *depends_on-default
36+ snuba-outcomes-consumer :
37+ << : *depends_on-default
38+ snuba-sessions-consumer :
39+ << : *depends_on-default
40+ snuba-transactions-consumer :
41+ << : *depends_on-default
42+ snuba-subscription-consumer-events :
43+ << : *depends_on-default
44+ snuba-subscription-consumer-transactions :
45+ << : *depends_on-default
46+ snuba-replacer :
47+ << : *depends_on-default
48+ symbolicator :
49+ << : *depends_on-default
3250 entrypoint : " /etc/sentry/entrypoint.sh"
3351 command : ["run", "web"]
3452 environment :
@@ -55,11 +73,11 @@ x-snuba-defaults: &snuba_defaults
5573 << : *restart_policy
5674 depends_on :
5775 clickhouse :
58- condition : service_healthy
76+ << : *depends_on-healthy
5977 kafka :
60- condition : service_healthy
78+ << : *depends_on-healthy
6179 redis :
62- condition : service_healthy
80+ << : *depends_on-healthy
6381 image : " $SNUBA_IMAGE"
6482 environment :
6583 SNUBA_SETTINGS : docker
@@ -143,7 +161,8 @@ services:
143161 kafka :
144162 << : *restart_policy
145163 depends_on :
146- - zookeeper
164+ zookeeper :
165+ << : *depends_on-healthy
147166 image : " confluentinc/cp-kafka:5.5.0"
148167 environment :
149168 KAFKA_ZOOKEEPER_CONNECT : " zookeeper:2181"
@@ -184,7 +203,11 @@ services:
184203 # You might want to change this to a higher value (and ensure your host has enough memory)
185204 MAX_MEMORY_USAGE_RATIO : 0.3
186205 healthcheck :
187- test : ["CMD-SHELL", "wget -nv -t1 --spider 'http://localhost:9000/' || exit 1"]
206+ test :
207+ [
208+ " CMD-SHELL" ,
209+ " wget -nv -t1 --spider 'http://localhost:9000/' || exit 1" ,
210+ ]
188211 interval : 3s
189212 timeout : 600s
190213 retries : 200
@@ -264,6 +287,14 @@ services:
264287 - " sentry-symbolicator:/data"
265288 web :
266289 << : *sentry_defaults
290+ healthcheck :
291+ << : *healthcheck_defaults
292+ test :
293+ - " CMD"
294+ - " /bin/bash"
295+ - ' -c'
296+ # Courtesy of https://unix.stackexchange.com/a/234089/108960
297+ - ' exec 3<>/dev/tcp/127.0.0.1/9000 && echo -e "GET /_health/ HTTP/1.1\r\nhost: 127.0.0.1\r\n\r\n" >&3 && grep ok -s -m 1 <&3'
267298 cron :
268299 << : *sentry_defaults
269300 command : run cron
@@ -318,9 +349,12 @@ services:
318349 source : ./geoip
319350 target : /geoip
320351 depends_on :
321- - kafka
322- - redis
323- - web
352+ kafka :
353+ << : *depends_on-healthy
354+ redis :
355+ << : *depends_on-healthy
356+ web :
357+ << : *depends_on-healthy
324358volumes :
325359 sentry-data :
326360 external : true
0 commit comments