-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
163 lines (155 loc) · 4.14 KB
/
Copy pathdocker-compose.yml
File metadata and controls
163 lines (155 loc) · 4.14 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
version: '3.8'
services:
# PostgreSQL Database
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-stellaiverse}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
POSTGRES_DB: ${POSTGRES_DB:-stellaiverse}
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U alian-structure"]
interval: 10s
timeout: 5s
retries: 5
security_opt:
- no-new-privileges:true
read_only: true
tmpfs:
- /tmp
- /var/run/postgresql
# Redis Cache
redis:
image: redis:7-alpine
command: redis-server --requirepass ${REDIS_PASSWORD:-CHANGE_ME_IN_PRODUCTION}
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 5s
retries: 5
security_opt:
- no-new-privileges:true
# Jaeger - Distributed Tracing
jaeger:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686" # Jaeger UI
- "4318:4318" # OTLP HTTP receiver
environment:
- COLLECTOR_OTLP_ENABLED=true
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:16686"]
interval: 10s
timeout: 5s
retries: 5
# Prometheus - Metrics Collection
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9090/-/healthy"]
interval: 10s
timeout: 5s
retries: 5
# Grafana - Visualization
grafana:
image: grafana/grafana:latest
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana_data:/var/lib/grafana
depends_on:
- prometheus
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health"]
interval: 10s
timeout: 5s
retries: 5
# NestJS Application
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
NODE_ENV: ${NODE_ENV:-development}
PORT: 3000
DATABASE_URL: postgresql://${POSTGRES_USER:-alian-structure}:${POSTGRES_PASSWORD:-CHANGE_ME_IN_PRODUCTION}@postgres:5432/${POSTGRES_DB:-alian-structure}
REDIS_URL: redis://default:${REDIS_PASSWORD:-CHANGE_ME_IN_PRODUCTION}@redis:6379
JWT_SECRET: ${JWT_SECRET:-GENERATE_WITH_GENERATE_SECRETS_SCRIPT}
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost:3001}
# Observability configuration
LOG_LEVEL: info
OTEL_EXPORTER_OTLP_ENDPOINT: http://jaeger:4318/v1/traces
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
jaeger:
condition: service_healthy
prometheus:
condition: service_healthy
volumes:
- .:/app
- /app/node_modules
command: npm run start:dev
security_opt:
- no-new-privileges:true
read_only: false
tmpfs:
- /tmp
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/v1/health"]
interval: 10s
timeout: 5s
retries: 5
# Production image (no source volume mounts) - builds the final runtime
app_prod:
build:
context: .
dockerfile: Dockerfile
target: runner
ports:
- "3000:3000"
environment:
NODE_ENV: production
PORT: 3000
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
command: node dist/main
restart: unless-stopped
security_opt:
- no-new-privileges:true
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/v1/health"]
interval: 10s
timeout: 5s
retries: 5
volumes:
postgres_data:
redis_data:
prometheus_data:
grafana_data: