-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
169 lines (160 loc) · 3.92 KB
/
docker-compose.yml
File metadata and controls
169 lines (160 loc) · 3.92 KB
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
version: '3.8'
services:
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: chillin-postgres
environment:
POSTGRES_DB: chillin_chatroom
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
- chatroom-network
# Redis for pub/sub and caching
redis:
image: redis:7-alpine
container_name: chillin-redis
command: redis-server --appendonly yes
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 3s
retries: 5
networks:
- chatroom-network
# MinIO for S3-compatible object storage
minio:
image: minio/minio:latest
container_name: chillin-minio
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
networks:
- chatroom-network
# Create MinIO bucket
minio-init:
image: minio/mc:latest
container_name: chillin-minio-init
depends_on:
- minio
entrypoint: >
/bin/sh -c "
sleep 5;
/usr/bin/mc config host add myminio http://minio:9000 minioadmin minioadmin;
/usr/bin/mc mb myminio/chillin-chatroom --ignore-existing;
/usr/bin/mc anonymous set public myminio/chillin-chatroom;
exit 0;
"
networks:
- chatroom-network
# API Server Instance 1
api-server-1:
build:
context: ./server
dockerfile: Dockerfile
container_name: chillin-api-1
environment:
PORT: 5000
NODE_ENV: development
CLIENT_ORIGIN: http://localhost:3000
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: chillin_chatroom
DB_USER: postgres
DB_PASSWORD: postgres
REDIS_URL: redis://redis:6379
USE_MINIO: "true"
MINIO_ENDPOINT: http://minio:9000
S3_ACCESS_KEY_ID: minioadmin
S3_SECRET_ACCESS_KEY: minioadmin
S3_BUCKET_NAME: chillin-chatroom
ports:
- "5001:5000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
networks:
- chatroom-network
restart: unless-stopped
# API Server Instance 2 (for horizontal scaling demonstration)
api-server-2:
build:
context: ./server
dockerfile: Dockerfile
container_name: chillin-api-2
environment:
PORT: 5000
NODE_ENV: development
CLIENT_ORIGIN: http://localhost:3000
DB_HOST: postgres
DB_PORT: 5432
DB_NAME: chillin_chatroom
DB_USER: postgres
DB_PASSWORD: postgres
REDIS_URL: redis://redis:6379
USE_MINIO: "true"
MINIO_ENDPOINT: http://minio:9000
S3_ACCESS_KEY_ID: minioadmin
S3_SECRET_ACCESS_KEY: minioadmin
S3_BUCKET_NAME: chillin-chatroom
ports:
- "5002:5000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
networks:
- chatroom-network
restart: unless-stopped
# Nginx Load Balancer
nginx:
image: nginx:alpine
container_name: chillin-nginx
ports:
- "5000:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- api-server-1
- api-server-2
networks:
- chatroom-network
restart: unless-stopped
volumes:
postgres_data:
redis_data:
minio_data:
networks:
chatroom-network:
driver: bridge