-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
255 lines (228 loc) · 5.69 KB
/
docker-compose.yml
File metadata and controls
255 lines (228 loc) · 5.69 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
version: '3.8' # Define a versão da especificação do Docker Compose
services:
# ======================
# Bancos de Dados
# ======================
postgres: # Instância principal do PostgreSQL
image: postgres:15
container_name: postgres
restart: always
ports:
- "5432:5432" # Porta padrão do PostgreSQL
environment:
POSTGRES_PASSWORD: example
networks:
- backend
mysql: # Banco MySQL
image: mysql:8
container_name: mysql
restart: always
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: example
networks:
- backend
mongodb: # Banco MongoDB
image: mongo:6
container_name: mongodb
restart: always
ports:
- "27017:27017"
networks:
- backend
redis: # Banco Redis (chave-valor em memória)
image: redis:7
container_name: redis
restart: always
ports:
- "6379:6379"
networks:
- backend
cassandra: # Banco Cassandra (NoSQL distribuído)
image: cassandra:4
container_name: cassandra
restart: always
ports:
- "9042:9042"
networks:
- backend
influxdb: # Banco InfluxDB (séries temporais)
image: influxdb:2
container_name: influxdb
restart: always
ports:
- "8086:8086"
networks:
- backend
elasticsearch: # Elasticsearch para indexação/buscas
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.2
container_name: elasticsearch
restart: always
environment:
- discovery.type=single-node # Configuração de nó único
- xpack.security.enabled=false # Desativa autenticação
ports:
- "9200:9200"
networks:
- backend
timescaledb: # TimescaleDB (extensão do PostgreSQL para séries temporais)
image: timescale/timescaledb:latest-pg15
container_name: timescaledb
restart: always
ports:
- "5433:5432" # Mapeia local 5433 → interno 5432
environment:
POSTGRES_PASSWORD: example
networks:
- backend
# ======================
# Exporters para Prometheus
# ======================
postgres_exporter:
image: prometheuscommunity/postgres-exporter
environment:
DATA_SOURCE_NAME: "postgresql://postgres:example@postgres:5432/postgres?sslmode=disable"
ports:
- "9187:9187"
depends_on:
- postgres # Espera o PostgreSQL estar pronto
networks:
- backend
mysql_exporter:
image: prometheus/mysqld-exporter
environment:
DATA_SOURCE_NAME: "root:example@(mysql:3306)/"
ports:
- "9104:9104"
depends_on:
- mysql
networks:
- backend
redis_exporter:
image: oliver006/redis_exporter
ports:
- "9121:9121"
depends_on:
- redis
networks:
- backend
mongodb_exporter:
image: bitnami/mongodb-exporter:latest
environment:
MONGODB_URI: "mongodb://mongodb:27017"
ports:
- "9216:9216"
depends_on:
- mongodb
networks:
- backend
cassandra_exporter:
image: criteord/cassandra_exporter
ports:
- "8080:8080"
depends_on:
- cassandra
networks:
- backend
elasticsearch_exporter:
image: quay.io/prometheuscommunity/elasticsearch-exporter
ports:
- "9114:9114"
environment:
- ES_URI=http://elasticsearch:9200
depends_on:
- elasticsearch
networks:
- backend
# ======================
# Monitoramento
# ======================
prometheus:
image: prom/prometheus
container_name: prometheus
restart: always
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml # Configuração externa
networks:
- backend
grafana:
image: grafana/grafana
container_name: grafana
restart: always
ports:
- "3000:3000" # Interface web do Grafana
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning # Dashboards e datasources pré-definidos
networks:
- backend
# ======================
# Balanceadores de carga
# ======================
nginx: # Nginx simples como proxy reverso
image: nginx
container_name: nginx
restart: always
ports:
- "8080:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
networks:
- backend
haproxy: # HAProxy como balanceador de carga avançado
image: haproxy:2.9
container_name: haproxy
restart: always
ports:
- "8888:80"
volumes:
- ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
networks:
- backend
# ======================
# Rede interna compartilhada
# ======================
# ======================
# PostgreSQL com replicação
# ======================
pg-primary:
image: postgres:16
container_name: pg_primary_us
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
POSTGRES_DB: app_db
volumes:
- pg_primary_data:/var/lib/postgresql/data
- ./primary/postgresql.conf:/etc/postgresql/postgresql.conf
ports:
- "5432:5432"
command: postgres -c config_file=/etc/postgresql/postgresql.conf
networks:
- global_pg_net
pg-replica:
image: postgres:16
container_name: pg_replica_br
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: root
volumes:
- pg_replica_data:/var/lib/postgresql/data
depends_on:
- pg-primary
ports:
- "5433:5432"
command: >
bash -c 'rm -rf /var/lib/postgresql/data/* && \
pg_basebackup -h pg-primary -D /var/lib/postgresql/data -U postgres -Fp -Xs -P -R && \
postgres'
networks:
- global_pg_net
volumes:
pg_primary_data:
pg_replica_data:
networks:
global_pg_net:
driver: bridge