-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
133 lines (121 loc) · 3.39 KB
/
docker-compose.yml
File metadata and controls
133 lines (121 loc) · 3.39 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
version: "3.8"
services:
# 1. Base de Datos (PostgreSQL) + HEALTHCHECK
db:
image: postgres:15
container_name: postgres_db_dataproject
restart: always
env_file:
- .env
ports:
- "5432:5432"
volumes:
- ./postgres_data_v2:/var/lib/postgresql/data
- ./init-db/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user_valencia -d contaminacion_db"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# 2. Infraestructura Kafka
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
kafka:
image: confluentinc/cp-kafka:7.5.0
ports:
- "9092:9092"
depends_on:
- zookeeper
env_file:
- .env
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
# 3. API Gateway (Ingesta + Lectura)
api_valencia:
build: .
container_name: api_service
command: uvicorn api_db:app --host 0.0.0.0 --port 8000
ports:
- "8000:8000"
# CAMBIO: Espera INTELIGENTE
depends_on:
db:
condition: service_healthy # <--- Espera a que el healthcheck diga OK
kafka:
condition: service_started
env_file:
- .env
# 4. Producer (Cliente HTTP Externo)
producer:
build: .
container_name: producer_client
command: python ingesta_producer.py
depends_on:
- api_valencia
env_file:
- .env
# 5. Consumer (Worker Interno)
consumer:
build: .
container_name: kafka_worker
command: python consumer_to_db.py
# CAMBIO: Espera INTELIGENTE
depends_on:
kafka:
condition: service_started
db:
condition: service_healthy # <--- Espera a que el healthcheck diga OK
env_file:
- .env
# 1. DASHBOARD PLOTLY (Streamlit)
dashboard:
build: ./dashboard # Construye desde la carpeta dashboard
container_name: visualization_plotly
ports:
- "8501:8501" # Puerto estándar de Streamlit
depends_on:
db:
condition: service_healthy
env_file:
- .env # Comparte las credenciales de DB
# 2. GRAFANA
grafana:
image: grafana/grafana:latest
container_name: visualization_grafana
ports:
- "3000:3000"
depends_on:
db:
condition: service_healthy
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin123 # Cambiar en producción
volumes:
- grafana_data:/var/lib/grafana
- ./grafana_config/provisioning/datasources:/etc/grafana/provisioning/datasources
- ./grafana_config/provisioning/dashboards:/etc/grafana/provisioning/dashboards
- ./grafana_config/dashboards:/var/lib/grafana/dashboards
# Nuevo Worker de IA
ml_worker:
build: .
container_name: ml_predictor_service
command: python ml_worker.py
depends_on:
kafka:
condition: service_started
db:
condition: service_healthy
env_file:
- .env
volumes:
postgres_data_v2:
grafana_data: # Volumen persistente para grafana