-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
352 lines (324 loc) · 8.96 KB
/
Copy pathdocker-compose.yml
File metadata and controls
352 lines (324 loc) · 8.96 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
services:
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: messenger-postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./scripts/init-databases.sql:/docker-entrypoint-initdb.d/init-databases.sql
networks:
- messenger-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache
redis:
image: redis:7-alpine
container_name: messenger-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- messenger-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# User Service
user-service:
build:
context: .
dockerfile: services/user/Dockerfile
container_name: messenger-user-service
environment:
# Server Configuration
GRPC_PORT: 50002
HTTP_PORT: 8002
SERVER_READ_TIMEOUT: 10s
SERVER_WRITE_TIMEOUT: 10s
# Database Configuration
DB_HOST: postgres
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: password
DB_NAME: messenger_user
DB_SSL_MODE: disable
DB_MAX_OPEN_CONNS: 25
DB_MAX_IDLE_CONNS: 5
DB_CONN_MAX_LIFETIME: 300s
# Cache Configuration
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: ""
REDIS_DB: 0
# Logging
LOG_LEVEL: info
LOG_FORMAT: json
# Environment
ENV: docker
ports:
- "50002:50002" # gRPC
- "8002:8002" # HTTP
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- messenger-network
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8002/health"]
interval: 30s
timeout: 10s
retries: 3
# Auth Service - FIXED JWT SECRETS
auth-service:
build:
context: .
dockerfile: services/auth/Dockerfile
container_name: messenger-auth-service
environment:
# Server Configuration
SERVER_PORT: 50001
APP_ENV: docker
# Database Configuration
DB_HOST: postgres
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: password
DB_NAME: messenger_auth
DB_SSL_MODE: disable
# Redis Configuration
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: ""
REDIS_DB: 0
# JWT Configuration - PROPER SECRETS THAT PASS VALIDATION
JWT_ACCESS_SECRET: "MessengerAccessSecret2024!@#$%^&*()AbCdEfGhIjKlMnOpQrStUvWxYz123456789"
JWT_REFRESH_SECRET: "MessengerRefreshSecret2024!@#$%^&*()ZyXwVuTsRqPoNmLkJiHgFeDcBa987654321"
JWT_ACCESS_TTL: 15m
JWT_REFRESH_TTL: 168h # 7 days
JWT_ISSUER: messenger-auth-service
# Logging
LOG_LEVEL: info
LOG_FORMAT: json
ports:
- "50001:50001" # gRPC
- "8001:8001" # HTTP (if needed)
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- messenger-network
restart: unless-stopped
# Chat Service
chat-service:
build:
context: .
dockerfile: services/chat/Dockerfile
container_name: messenger-chat-service
environment:
# Chat service expects CHAT_* prefixed variables
CHAT_GRPC_PORT: 50003
CHAT_HTTP_PORT: 8003
# Database Configuration
DB_HOST: postgres
DB_PORT: 5432
DB_USER: postgres
DB_PASSWORD: password
DB_NAME: messenger_chat
DB_SSL_MODE: disable
# Redis Configuration (Chat service expects CHAT_REDIS_* variables)
CHAT_REDIS_HOST: redis
CHAT_REDIS_PORT: 6379
CHAT_REDIS_PASSWORD: ""
CHAT_REDIS_DB: 2
# Environment
ENV: docker
ports:
- "50003:50003" # gRPC
- "8003:8003" # HTTP
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- messenger-network
restart: unless-stopped
# Subscriber Service
subscriber-service:
build:
context: .
dockerfile: services/subscriber/Dockerfile
container_name: messenger-subscriber-service
environment:
# Server Configuration (matching config.go expectations)
SUBSCRIBER_GRPC_PORT: 50004
SUBSCRIBER_HTTP_PORT: 8004
# Database Configuration
SUBSCRIBER_DB_HOST: postgres
SUBSCRIBER_DB_PORT: 5432
SUBSCRIBER_DB_USER: postgres
SUBSCRIBER_DB_PASSWORD: password
SUBSCRIBER_DB_NAME: messenger_subscriber
SUBSCRIBER_DB_SSLMODE: disable
# Redis Configuration
SUBSCRIBER_REDIS_HOST: redis
SUBSCRIBER_REDIS_PORT: 6379
SUBSCRIBER_REDIS_PASSWORD: ""
SUBSCRIBER_REDIS_DB: 3
# Application Configuration
APP_ENV: docker
ports:
- "50004:50004" # gRPC
- "8004:8004" # HTTP
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- messenger-network
restart: unless-stopped
# Gateway Service - UPDATED WITH MATCHING JWT SECRET AND PROPER DEPENDENCIES
gateway-service:
build:
context: .
dockerfile: services/gateway/Dockerfile
container_name: messenger-gateway
environment:
HTTP_PORT: 8000
AUTH_SERVICE_URL: auth-service:50001
USER_SERVICE_URL: user-service:50002
CHAT_SERVICE_URL: chat-service:50003
SUBSCRIBER_SERVICE_URL: subscriber-service:50004
# JWT_SECRET should match JWT_ACCESS_SECRET from auth-service
JWT_SECRET: "MessengerAccessSecret2024!@#$%^&*()AbCdEfGhIjKlMnOpQrStUvWxYz123456789"
ENV: docker
ports:
- "8000:8000" # Gateway HTTP
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
auth-service:
condition: service_started
user-service:
condition: service_started
chat-service:
condition: service_started
subscriber-service:
condition: service_started
networks:
- messenger-network
restart: unless-stopped
# Database Migration Tool - User Service
migrate-user:
image: migrate/migrate
container_name: messenger-migrate-user
profiles: ["migration"]
volumes:
- ./services/user/migrations:/migrations
command: >
-path=/migrations
-database=postgres://postgres:password@postgres:5432/messenger_user?sslmode=disable
up
depends_on:
postgres:
condition: service_healthy
networks:
- messenger-network
# Database Migration Tool - Auth Service
migrate-auth:
image: migrate/migrate
container_name: messenger-migrate-auth
profiles: ["migration"]
volumes:
- ./services/auth/migrations:/migrations
command: >
-path=/migrations
-database=postgres://postgres:password@postgres:5432/messenger_auth?sslmode=disable
up
depends_on:
postgres:
condition: service_healthy
networks:
- messenger-network
# Database Migration Tool - Chat Service
migrate-chat:
image: migrate/migrate
container_name: messenger-migrate-chat
profiles: ["migration"]
volumes:
- ./services/chat/migrations:/migrations
command: >
-path=/migrations
-database=postgres://postgres:password@postgres:5432/messenger_chat?sslmode=disable
up
depends_on:
postgres:
condition: service_healthy
networks:
- messenger-network
# Database Migration Tool - Subscriber Service
migrate-subscriber:
image: migrate/migrate
container_name: messenger-migrate-subscriber
profiles: ["migration"]
volumes:
- ./services/subscriber/migrations:/migrations
command: >
-path=/migrations
-database=postgres://postgres:password@postgres:5432/messenger_subscriber?sslmode=disable
up
depends_on:
postgres:
condition: service_healthy
networks:
- messenger-network
# Combined Migration Service - runs all migrations
migrate:
image: migrate/migrate
container_name: messenger-migrate-all
profiles: ["migration"]
volumes:
- ./services/user/migrations:/user-migrations
- ./services/auth/migrations:/auth-migrations
- ./scripts/run-all-migrations.sh:/run-migrations.sh
entrypoint: ["/bin/sh", "/run-migrations.sh"]
depends_on:
postgres:
condition: service_healthy
networks:
- messenger-network
# Adminer for database management
adminer:
image: adminer
container_name: messenger-adminer
ports:
- "8080:8080"
depends_on:
- postgres
networks:
- messenger-network
volumes:
postgres_data:
redis_data:
networks:
messenger-network:
driver: bridge