forked from hantsy/spring-microservice-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-stack.yml
157 lines (146 loc) · 3.15 KB
/
docker-stack.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
version: '3.4' # specify docker-compose version
services:
nginx-proxy:
image: hantsy/nginx-proxy
ports:
- "80:80"
networks:
- frontend
- backend
depends_on:
- auth-service
- user-service
- post-service
deploy:
mode: replicated
replicas: 2
labels: [APP=GATEWAY]
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 3
window: 120s
placement:
constraints: [node.role == manager]
auth-service:
image: hantsy/auth-service
environment:
SERVICES_USER_SERVICE_URL: http://user-service:8001
SPRING_REDIS_HOST: redis
ports:
- "8000:8000" #specify ports forewarding
networks:
- backend
depends_on:
- redis
- user-service
deploy:
replicas: 1
labels: [APP=AUTHSERVICE]
update_config:
parallelism: 2
restart_policy:
condition: on-failure
user-service:
image: hantsy/user-service
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://userdb:3306/userdb
SPRING_REDIS_HOST: redis
ports:
- "8001:8001" #specify ports forewarding
networks:
- backend
depends_on:
- redis
- userdb
deploy:
replicas: 1
labels: [APP=USERSERVICE]
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
post-service:
image: hantsy/post-service
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postdb:5432/postdb
SPRING_REDIS_HOST: redis
ports:
- "8002:8002" #specify ports forewarding
networks:
- backend
depends_on:
- redis
- postdb
deploy:
replicas: 3
labels: [APP=POSTSERVICE]
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
visualizer:
image: dockersamples/visualizer:stable
ports:
- "8080:8080"
stop_grace_period: 1m30s
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
- frontend
deploy:
placement:
constraints: [node.role == manager]
userdb:
image: mysql
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: mysecret
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: userdb
volumes:
- userdata:/var/lib/mysql
networks:
- backend
deploy:
placement:
constraints: [node.role == worker]
postdb:
image: postgres
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: password
POSTGRES_DB: postdb
volumes:
- postdata:/var/lib/mysql
networks:
- backend
deploy:
placement:
constraints: [node.role == worker]
redis:
image: redis
ports:
- "6379:6379"
networks:
- backend
deploy:
replicas: 1
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
placement:
constraints: [node.role == worker]
networks:
frontend:
backend:
volumes:
userdata:
postdata: