File tree 3 files changed +55
-5
lines changed
3 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 1
- version : " 3"
1
+ # version is now using "compose spec"
2
+ # v2 and v3 are now combined!
3
+ # docker-compose v1.27+ required
2
4
3
5
services :
4
6
vote :
5
7
build : ./vote
8
+ # use python rather than gunicorn for local dev
6
9
command : python app.py
10
+ depends_on :
11
+ redis :
12
+ condition : service_healthy
7
13
volumes :
8
14
- ./vote:/app
9
15
ports :
@@ -14,7 +20,11 @@ services:
14
20
15
21
result :
16
22
build : ./result
23
+ # use nodemon rather than node for local dev
17
24
command : nodemon server.js
25
+ depends_on :
26
+ db :
27
+ condition : service_healthy
18
28
volumes :
19
29
- ./result:/app
20
30
ports :
@@ -28,26 +38,35 @@ services:
28
38
build :
29
39
context : ./worker
30
40
depends_on :
31
- - " redis"
32
- - " db"
41
+ redis :
42
+ condition : service_healthy
43
+ db :
44
+ condition : service_healthy
33
45
networks :
34
46
- back-tier
35
47
36
48
redis :
37
49
image : redis:5.0-alpine3.10
38
- container_name : redis
50
+ volumes :
51
+ - " ./healthchecks:/healthchecks"
52
+ healthcheck :
53
+ test : /healthchecks/redis.sh
54
+ interval : " 5s"
39
55
ports : ["6379"]
40
56
networks :
41
57
- back-tier
42
58
43
59
db :
44
60
image : postgres:9.4
45
- container_name : db
46
61
environment :
47
62
POSTGRES_USER : " postgres"
48
63
POSTGRES_PASSWORD : " postgres"
49
64
volumes :
50
65
- " db-data:/var/lib/postgresql/data"
66
+ - " ./healthchecks:/healthchecks"
67
+ healthcheck :
68
+ test : /healthchecks/postgres.sh
69
+ interval : " 5s"
51
70
networks :
52
71
- back-tier
53
72
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -eo pipefail
3
+
4
+ host=" $( hostname -i || echo ' 127.0.0.1' ) "
5
+ user=" ${POSTGRES_USER:- postgres} "
6
+ db=" ${POSTGRES_DB:- $POSTGRES_USER } "
7
+ export PGPASSWORD=" ${POSTGRES_PASSWORD:- } "
8
+
9
+ args=(
10
+ # force postgres to not use the local unix socket (test "external" connectibility)
11
+ --host " $host "
12
+ --username " $user "
13
+ --dbname " $db "
14
+ --quiet --no-align --tuples-only
15
+ )
16
+
17
+ if select=" $( echo ' SELECT 1' | psql " ${args[@]} " ) " && [ " $select " = ' 1' ]; then
18
+ exit 0
19
+ fi
20
+
21
+ exit 1
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ set -eo pipefail
3
+
4
+ host=" $( hostname -i || echo ' 127.0.0.1' ) "
5
+
6
+ if ping=" $( redis-cli -h " $host " ping) " && [ " $ping " = ' PONG' ]; then
7
+ exit 0
8
+ fi
9
+
10
+ exit 1
You can’t perform that action at this time.
0 commit comments