-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
219 lines (212 loc) · 6.2 KB
/
Copy pathdocker-compose.yml
File metadata and controls
219 lines (212 loc) · 6.2 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
services:
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: notif-postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB:-POSTGRES_DB}
ports:
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./infrastructure/docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- notif-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U notif_user -d notification_system"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache
redis:
image: redis:7-alpine
container_name: notif-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- notif-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# RabbitMQ Message Queue
rabbitmq:
image: rabbitmq:3.12-management
container_name: notif-rabbitmq
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-guest}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-guest}
ports:
- "5672:5672" # AMQP port
- "15672:15672" # Management UI
volumes:
- rabbitmq_data:/var/lib/rabbitmq
- ./infrastructure/docker/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
networks:
- notif-network
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "ping"]
interval: 30s
timeout: 10s
retries: 5
# API Gateway (NodeJS/Fastify)
api-gateway:
build:
context: ./services/api-gateway
dockerfile: Dockerfile
container_name: notif-api-gateway
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- API_GATEWAY_PORT=3000
- DATABASE_URL=postgresql://notif_user:notif_password@postgres:5432/notification_system
- RABBITMQ_HOST=rabbitmq
- RABBITMQ_PORT=5672
- RABBITMQ_USER=guest
- RABBITMQ_PASSWORD=guest
- RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672
- USER_SERVICE_URL=http://user-service:3002
- USER_SERVICE_BASE_URL=http://user-service:3002
- TEMPLATE_SERVICE_URL=http://template-service:3004
- TEMPLATE_SERVICE_BASE_URL=http://template-service:3004
- JWT_SECRET=HAD_12X#@
- SERVICE_TOKEN=internal-service-token
volumes:
- /app/node_modules
depends_on:
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
networks:
- notif-network
command: sh -c "npx prisma migrate deploy 2>/dev/null; npx prisma db push --accept-data-loss && npm run start"
# Email Service (NestJS)
email-service:
build:
context: ./services/email-service
dockerfile: Dockerfile
container_name: notif-email-service
ports:
- "3001:3001"
environment:
- NODE_ENV=development
- PORT=3001
- RABBITMQ_HOST=rabbitmq
- RABBITMQ_PORT=5672
- RABBITMQ_USER=guest
- RABBITMQ_PASSWORD=guest
- RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672
- RABBITMQ_EMAIL_QUEUE=email.queue
- RABBITMQ_FAILED_QUEUE=failed.queue
- EMAIL_PROVIDER=sendgrid
- SENDGRID_API_KEY=${SENDGRID_API_KEY}
- SENDGRID_FROM_EMAIL=obrienadedapo15@gmail.com
- SENDGRID_FROM_NAME="Group 43 Notification System"
- SMTP_HOST=smtp.gmail.com
- SMTP_PORT=465
- SMTP_SECURE=true
- SMTP_USER=obrienadedapo15@gmail.com
- SMTP_PASSWORD=${SMTP_PASSWORD}
- SMTP_FROM_EMAIL=obrienadedapo15@gmail.com
- SMTP_FROM_NAME="Group 43 Notification System"
- TEMPLATE_SERVICE_URL=http://template-service:3004
- API_GATEWAY_URL=http://api-gateway:3000
- MAX_RETRIES=5
- RETRY_DELAY_MS=1000
- CIRCUIT_BREAKER_TIMEOUT=10000
- CIRCUIT_BREAKER_ERROR_THRESHOLD=50
- CIRCUIT_BREAKER_RESET_TIMEOUT=30000
volumes:
- ./services/email-service:/app
- /app/node_modules
depends_on:
rabbitmq:
condition: service_healthy
networks:
- notif-network
command: npm run start:dev
# User Service (NestJS)
user-service:
build:
context: ./services/user-service/
dockerfile: Dockerfile
container_name: notif-user-service
ports:
- "3002:3002"
environment:
- NODE_ENV=development
- PORT=3002
- DATABASE_URL=postgresql://notif_user:notif_password@postgres:5432/notification_system
- REDIS_HOST=redis
volumes:
- ./services/user-service:/app
- /app/node_modules
depends_on:
redis:
condition: service_healthy
networks:
- notif-network
command: npm run start:dev
# Push Service (Python)
push-service:
build:
context: ./services/push-service
dockerfile: Dockerfile
container_name: notif-push-service
ports:
- "3003:3003"
environment:
- PYTHONUNBUFFERED=1
- PORT=3003
- RABBITMQ_URL=amqp://guest:guest@rabbitmq:5672/
- TEMPLATE_SERVICE_URL=http://template-service:3004
- REDIS_URL=redis://redis:6379
- FIREBASE_PROJECT_ID=notification-system-24c7a
- GOOGLE_APPLICATION_CREDENTIALS=./serviceAccount.json
volumes:
- ./services/push-service:/app
depends_on:
rabbitmq:
condition: service_healthy
redis:
condition: service_healthy
networks:
- notif-network
command: uvicorn src.main:app --host 0.0.0.0 --port 3003 --reload
# Template Service (Python)
template-service:
build:
context: ./services/template-service
dockerfile: Dockerfile
container_name: notif-template-service
ports:
- "3004:3004"
environment:
- PYTHONUNBUFFERED=1
- PORT=3004
- DATABASE_URL=postgresql+psycopg://notif_user:notif_password@postgres:5432/notification_system
- REDIS_URL=redis://redis:6379
volumes:
- ./services/template-service:/app
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- notif-network
command: uvicorn src.main:app --host 0.0.0.0 --port 3004 --reload
volumes:
postgres_data:
redis_data:
rabbitmq_data:
networks:
notif-network:
driver: bridge