-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
82 lines (76 loc) · 2.02 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
version: '3.8'
services:
mysql:
container_name: "server-mysql"
volumes:
- mysql_data:/var/lib/mysql
image: mysql:8
restart: always
environment:
MYSQL_ROOT_PASSWORD: "password"
MYSQL_DATABASE: "test_db"
ports:
- "3306:3306"
redis:
image: redis
container_name: redis
command: sh -c "redis-server --appendonly yes && redis-cli flushall"
volumes:
- redis_data:/data
restart: always
api-server:
container_name: "api-server"
image: "api-server"
build: .
command: bash -c 'while !</dev/tcp/mysql/3306; do echo "waiting for mysql to be ready...."; sleep 5; done; npm run start'
ports:
- "3000:3000"
env_file:
- .env.docker
environment:
REST_API_SERVER_ENV: "production"
depends_on:
- mysql
- redis
load-balancer:
image: haproxy
ports:
- "4000:4000"
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
depends_on:
- tcp-server1
- tcp-server2
tcp-server1:
build: .
container_name: tcp-server1
# command: sh -c "node ./tcp/server.js"
command: bash -c 'while ! curl -sSf http://api-server:3000/health > /dev/null; do echo "Waiting for API server to be ready...."; sleep 10; done; node ./tcp-server.js'
environment:
SERVER_ID: 1000
REDIS_HOST: redis
REDIS_PORT: 6379
TCP_HOST: '0.0.0.0'
TCP_PORT: 4000
REST_API_SERVER_HOST: 'api-server'
depends_on:
- redis
- api-server
tcp-server2:
build: .
container_name: tcp-server2
# command: sh -c "node ./tcp/server.js"
command: bash -c 'while ! curl -sSf http://api-server:3000/health > /dev/null; do echo "Waiting for API server to be ready...."; sleep 10; done; node ./tcp-server.js'
environment:
SERVER_ID: 1001
REDIS_HOST: redis
REDIS_PORT: 6379
TCP_HOST: '0.0.0.0'
TCP_PORT: 4000
REST_API_SERVER_HOST: 'api-server'
depends_on:
- redis
- api-server
volumes:
redis_data:
mysql_data: