-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
216 lines (205 loc) · 5.88 KB
/
docker-compose.yml
File metadata and controls
216 lines (205 loc) · 5.88 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
# NEXO CRM System - Docker Compose
# ==================================
# Complete multi-service orchestration for development/production
version: '3.8'
services:
# PostgreSQL Database with Multi-tenant support
postgres:
image: postgres:16-alpine
container_name: nexo-postgres
restart: unless-stopped
environment:
POSTGRES_DB: ${POSTGRES_DB:-nexo}
POSTGRES_USER: ${POSTGRES_USER:-nexo_user}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-nexo_password}
POSTGRES_HOST_AUTH_METHOD: ${POSTGRES_HOST_AUTH_METHOD:-scram-sha-256}
POSTGRES_INITDB_ARGS: '--auth-host=scram-sha-256'
ports:
- "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database/init:/docker-entrypoint-initdb.d:ro
networks:
- nexo-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-nexo_user} -d ${POSTGRES_DB:-nexo}"]
interval: 10s
timeout: 5s
retries: 5
# Redis Cache
redis:
image: redis:7-alpine
container_name: nexo-redis
restart: unless-stopped
command: redis-server --requirepass ${REDIS_PASSWORD:-nexo_redis_password}
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
networks:
- nexo-network
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 5s
retries: 5
# RabbitMQ Message Queue
rabbitmq:
image: rabbitmq:3-management-alpine
container_name: nexo-rabbitmq
restart: unless-stopped
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-nexo_user}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-nexo_password}
ports:
- "${RABBITMQ_PORT:-5672}:5672"
- "${RABBITMQ_MANAGEMENT_PORT:-15672}:15672"
volumes:
- rabbitmq_data:/var/lib/rabbitmq
networks:
- nexo-network
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "ping"]
interval: 10s
timeout: 5s
retries: 5
# Auth Service
auth-service:
build:
context: ./nexo-prj
dockerfile: apps/auth-service/Dockerfile
container_name: nexo-auth-service
restart: unless-stopped
ports:
- "${AUTH_SERVICE_PORT:-3001}:3000"
environment:
- NODE_ENV=${NODE_ENV:-production}
- PORT=3000
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=${POSTGRES_DB:-nexo}
- DB_USER=${POSTGRES_USER:-nexo_user}
- DB_PASSWORD=${POSTGRES_PASSWORD:-nexo_password}
- JWT_SECRET=${JWT_SECRET:-your-super-secret-jwt-key-change-in-production}
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-1h}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-nexo_redis_password}
networks:
- nexo-network
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# API Gateway
api-gateway:
build:
context: ./nexo-prj
dockerfile: apps/api-gateway/Dockerfile
container_name: nexo-api-gateway
restart: unless-stopped
ports:
- "${API_GATEWAY_PORT:-3002}:3000"
environment:
- NODE_ENV=${NODE_ENV:-production}
- PORT=3000
- AUTH_SERVICE_URL=http://auth-service:3000
- CRM_SERVICE_URL=http://crm-service:3000
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-nexo_redis_password}
networks:
- nexo-network
depends_on:
auth-service:
condition: service_healthy
crm-service:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# CRM Service
crm-service:
build:
context: ./nexo-prj
dockerfile: apps/crm-service/Dockerfile
container_name: nexo-crm-service
restart: unless-stopped
ports:
- "${CRM_SERVICE_PORT:-3003}:3000"
environment:
- NODE_ENV=${NODE_ENV:-production}
- PORT=3000
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=${POSTGRES_DB:-nexo}
- DB_USER=${POSTGRES_USER:-nexo_user}
- DB_PASSWORD=${POSTGRES_PASSWORD:-nexo_password}
- RABBITMQ_URL=amqp://${RABBITMQ_USER:-nexo_user}:${RABBITMQ_PASSWORD:-nexo_password}@rabbitmq:5672
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-nexo_redis_password}
networks:
- nexo-network
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
rabbitmq:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Frontend development server
frontend:
build:
context: .
dockerfile: Dockerfile.dev
container_name: nexo-frontend-dev
ports:
- "${FRONTEND_PORT:-3000}:3000"
volumes:
- ./nexo-prj:/app
- /app/node_modules
- /app/.next
environment:
- NODE_ENV=${NODE_ENV:-development}
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-http://localhost:3002}
networks:
- nexo-network
depends_on:
api-gateway:
condition: service_healthy
command: pnpm exec nx serve nexo-prj --host 0.0.0.0 --port 3000
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
nexo-network:
driver: bridge
volumes:
postgres_data:
driver: local
redis_data:
driver: local
rabbitmq_data:
driver: local
node_modules:
next_cache: