-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdocker-compose.yml
170 lines (160 loc) · 4.23 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
volumes:
redis_1_data: {}
redis_2_data: {}
redis_3_data: {}
redis_4_data: {}
redis_5_data: {}
redis_6_data: {}
# This volume is specific for the demo Express application
# built in this repo. You probably won't need that on your own setup.
node_modules: {}
services:
app:
container_name: express_app
build:
context: .
environment:
PORT: 4000
NODE_ENV: production
REDIS_CLUSTER_URLS: "redis_1:6379,redis_2:6379,redis_3:6379,redis_4:6379,redis_5:6379,redis_6:6379"
volumes:
- .:/app
- node_modules:/app/node_modules
command: ["npm", "run", "dev"]
depends_on:
- redis_1
- redis_2
- redis_3
- redis_4
- redis_5
- redis_6
- cluster_initiator
ports:
- "4000:4000"
stdin_open: true
networks:
redis_cluster_net:
ipv4_address: 173.18.0.10
# Here we have six Redis containers with Cluster mode enabled,
# three of them will work as master nodes and each one of
# will have a replica, so in case of failures, the replica becomes the master.
# They are configured by the `cluster_initiator` container.
redis_1:
image: "redis:latest"
container_name: redis_1
ports:
- "6379"
volumes:
- redis_1_data:/data
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
networks:
redis_cluster_net:
ipv4_address: 173.18.0.2
redis_2:
image: "redis:latest"
container_name: redis_2
ports:
- "6379"
volumes:
- redis_2_data:/data
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
networks:
redis_cluster_net:
ipv4_address: 173.18.0.3
redis_3:
image: "redis:latest"
container_name: redis_3
ports:
- "6379"
volumes:
- redis_3_data:/data
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
networks:
redis_cluster_net:
ipv4_address: 173.18.0.4
redis_4:
image: "redis:latest"
container_name: redis_4
ports:
- "6379"
volumes:
- redis_4_data:/data
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
networks:
redis_cluster_net:
ipv4_address: 173.18.0.5
redis_5:
image: "redis:latest"
container_name: redis_5
ports:
- "6379"
volumes:
- redis_5_data:/data
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
networks:
redis_cluster_net:
ipv4_address: 173.18.0.6
redis_6:
image: "redis:latest"
container_name: redis_6
ports:
- "6379"
volumes:
- redis_6_data:/data
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
networks:
redis_cluster_net:
ipv4_address: 173.18.0.7
# Ephemeral container to create the Redis cluster connections.
# Once the setup is done, this container shuts down
# and the cluster can be used by the service app container
cluster_initiator:
container_name: cluster_initiator
build:
context: redis
dockerfile: Dockerfile
tty: true
depends_on:
- redis_1
- redis_2
- redis_3
- redis_4
- redis_5
- redis_6
networks:
redis_cluster_net:
ipv4_address: 173.18.0.8
# Web UI to browse through our Redis data across all nodes
redis_commander:
image: rediscommander/redis-commander:latest
container_name: redis_web
environment:
REDIS_HOSTS: "local:redis_1:6379,local:redis_2:6379,local:redis_3:6379"
ports:
- "5050:8081"
depends_on:
- redis_1
- redis_2
- redis_3
- redis_4
- redis_5
- redis_6
- cluster_initiator
networks:
redis_cluster_net:
ipv4_address: 173.18.0.9
# Rename the default network so we can easily identify it
# Across all containers
networks:
redis_cluster_net:
driver: bridge
ipam:
driver: default
config:
- subnet: 173.18.0.0/16