-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
221 lines (209 loc) · 5.44 KB
/
docker-compose.yml
File metadata and controls
221 lines (209 loc) · 5.44 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
version: '3.8'
services:
# Development database
postgres:
image: postgres:15-alpine
container_name: devops-postgres
environment:
POSTGRES_DB: devops_db
POSTGRES_USER: devops_user
POSTGRES_PASSWORD: devops_password
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
networks:
- devops-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U devops_user -d devops_db"]
interval: 30s
timeout: 10s
retries: 3
# Redis for caching
redis:
image: redis:7-alpine
container_name: devops-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- devops-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
# Sample web application
web:
build:
context: ./templates/basic-web-app
dockerfile: Dockerfile
container_name: devops-web
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://devops_user:devops_password@postgres:5432/devops_db
- REDIS_URL=redis://redis:6379
- PORT=3000
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- devops-network
volumes:
- ./templates/basic-web-app:/app
- /app/node_modules
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
# Nginx reverse proxy
nginx:
image: nginx:alpine
container_name: devops-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./configs/docker/nginx.conf:/etc/nginx/nginx.conf
- ./ssl:/etc/nginx/ssl
depends_on:
- web
networks:
- devops-network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
# Monitoring with Prometheus
prometheus:
image: prom/prometheus:latest
container_name: devops-prometheus
ports:
- "9090:9090"
volumes:
- ./configs/docker/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
networks:
- devops-network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9090/-/healthy"]
interval: 30s
timeout: 10s
retries: 3
# Grafana for visualization
grafana:
image: grafana/grafana:latest
container_name: devops-grafana
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana_data:/var/lib/grafana
- ./configs/grafana/provisioning:/etc/grafana/provisioning
depends_on:
- prometheus
networks:
- devops-network
healthcheck:
test: ["CMD-SHELL", "wget --quiet --tries=1 --spider http://localhost:3000/api/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
# Jaeger for distributed tracing
jaeger:
image: jaegertracing/all-in-one:latest
container_name: devops-jaeger
ports:
- "16686:16686"
- "14268:14268"
environment:
- COLLECTOR_OTLP_ENABLED=true
networks:
- devops-network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:16686/"]
interval: 30s
timeout: 10s
retries: 3
# Elasticsearch for logging
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.8.0
container_name: devops-elasticsearch
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ports:
- "9200:9200"
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
networks:
- devops-network
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
# Kibana for log visualization
kibana:
image: docker.elastic.co/kibana/kibana:8.8.0
container_name: devops-kibana
ports:
- "5601:5601"
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
depends_on:
- elasticsearch
networks:
- devops-network
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:5601/api/status || exit 1"]
interval: 30s
timeout: 10s
retries: 3
# Next.js Website
website:
build:
context: ./nextjs-app
dockerfile: Dockerfile
container_name: devops-website
ports:
- "3002:3000"
environment:
- NODE_ENV=production
networks:
- devops-network
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
volumes:
postgres_data:
redis_data:
prometheus_data:
grafana_data:
elasticsearch_data:
networks:
devops-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16