-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
226 lines (212 loc) · 7 KB
/
docker-compose.yml
File metadata and controls
226 lines (212 loc) · 7 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
version: '3.8'
# Docker Compose configuration for QueryHawk with Grafana Alloy
services: # This section defines all the services (containers) we want to run
# Supabase - Our main database and auth service
# Runs PostgreSQL and provides real-time capabilities
#format is host_port:container_port
# Test database to simulate a user's external PostgreSQL instance
# test_user_db:
# image: postgres:13
# ports:
# - '5433:5432'
# environment:
# POSTGRES_PASSWORD: testpass123
# POSTGRES_USER: testuser
# POSTGRES_DB: testdb
# volumes:
# - ./test-init.sql:/docker-entrypoint-initdb.d/test-init.sql
# networks:
# - queryhawk_monitoring_network # Uses the default network created by docker-compose
# postgres-exporter:
# image: prometheuscommunity/postgres-exporter
# environment:
# - DATA_SOURCE_NAME=postgresql://testuser:testpass123@test_user_db:5432/testdb?sslmode=disable
# ports:
# - '9187:9187'
# networks:
# - queryhawk_monitoring_networkhec
# depends_on:
# - test_user_db
# Express Backend - Handles our API and query monitoring
backend:
build:
context: .
dockerfile: server/Dockerfile # Builds using server folder's Dockerfile
ports:
- '4002:4002' # API will be available on localhost:4002
dns:
- 8.8.8.8
- 1.1.1.1
volumes:
# All these volume mappings enable development with hot reloading
- ./server:/app/server # Maps local server code to container
- ./types:/app/types # Maps local types directory for TypeScript types
- ./package.json:/app/package.json # Maps package.json for npm commands
- ./tsconfig.json:/app/tsconfig.json # Maps TypeScript config
- /app/node_modules # Preserves container's node_modules
- /var/run/docker.sock:/var/run/docker.sock
- ./grafana-alloy/targets:/app/grafana-alloy/targets
env_file:
- .env
environment:
- PORT=4002
- DATABASE_URL=${POSTGRES_URI}
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET}
- CORS_ORIGIN=http://localhost:5173
- JWT_SECRET=${JWT_SECRET}
- SUPABASE_URI=${SUPABASE_URI}
- NODE_ENV=development
- OTEL_EXPORTER_OTLP_ENDPOINT=http://grafana-alloy:14318/v1/traces # OTLP HTTP endpoint for Grafana Alloy
- OTEL_SERVICE_NAME=queryhawk-backend
- OTEL_SERVICE_VERSION=1.0.0
depends_on:
- jaeger
networks:
- queryhawk_monitoring_network
deploy:
resources:
limits:
memory: 768M
jaeger: # This is the name we're giving to our service
image: jaegertracing/all-in-one:latest
#ports section maps ports from container to computer
#format is host_port:container_port
ports:
- '6831:6831/udp' # Jaeger thrift compact protocol
- '6832:6832/udp' # Jaeger thrift binary protocol
- '5778:5778' # Jaeger admin port
- '16686:16686' # Jaeger UI
- '4317:4317' # OTLP gRPC
- '4318:4318' # OTLP HTTP
environment:
- COLLECTOR_OTLP_ENABLED=true
networks:
- queryhawk_monitoring_network
deploy:
resources:
limits:
memory: 512M
# Loki - Log aggregation and querying
loki:
image: grafana/loki:2.9.0
ports:
- '3100:3100' # Loki HTTP API
command: -config.file=/etc/loki/local-config.yaml
volumes:
- ./loki/local-config.yaml:/etc/loki/local-config.yaml
- loki_data:/loki
networks:
- queryhawk_monitoring_network
deploy:
resources:
limits:
memory: 512M
# Mimir - Long-term metrics storage and Prometheus-compatible API
mimir:
image: grafana/mimir:2.10.0
ports:
- '9009:9009' # Mimir HTTP API
- '9095:9095' # Mimir gRPC API
command: -config.file=/etc/mimir/mimir.yaml
volumes:
- ./mimir/mimir.yaml:/etc/mimir/mimir.yaml
- mimir_data:/data
environment:
- MIMIR_CONFIG=/etc/mimir/mimir.yaml
networks:
- queryhawk_monitoring_network
deploy:
resources:
limits:
memory: 1G
# Grafana Alloy - Metrics collection and processing
grafana-alloy:
build:
context: ./grafana-alloy
dockerfile: Dockerfile
ports:
- '12345:12345' # Alloy HTTP port
- '12346:12346' # Alloy gRPC port
- '14317:14317' # OTLP gRPC receiver
- '14318:14318' # OTLP HTTP receiver
volumes:
- ./grafana-alloy/config.river:/etc/alloy/config.river
- ./grafana-alloy/targets:/etc/alloy/targets
- ./grafana-alloy/targets:/app/targets
depends_on:
- mimir
- loki
- grafana
networks:
- queryhawk_monitoring_network
deploy:
resources:
limits:
memory: 768M
# Prometheus service removed - Alloy handles metrics collection and sends to Grafana
# Grafana - Creates dashboards from our metrics
grafana:
image: grafana/grafana # Official Grafana image
ports:
- '3001:3000' # Dashboard available on localhost:3001
environment:
- GF_SECURITY_ALLOW_EMBEDDING=true
- GF_AUTH_ANONYMOUS_ENABLED=false
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
- GF_SECURITY_CORS_ENABLED=true
- GF_SECURITY_CORS_ALLOW_ORIGIN=http://localhost:5173
- GF_AUTH_DISABLE_LOGIN_FORM=false
- GF_AUTH_BASIC_ENABLED=false
- GF_FEATURE_TOGGLES_ENABLE=publicDashboards
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
volumes:
# Persist dashboard configurations and data
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
- ./grafana/dashboards:/var/lib/grafana/dashboards
depends_on:
- backend # Needs backend to start first
networks:
- queryhawk_monitoring_network
deploy:
resources:
limits:
memory: 768M
# React Frontend - Our user interface
frontend:
build:
context: . # This should be where your frontend Dockerfile is
dockerfile: src/Dockerfile # Path to your development Dockerfile
ports:
- '5173:5173' # Website available on localhost:3000
volumes:
# Hot reloading for development
- ./:/app/ # Maps local code to container
- /app/node_modules # Keeps node_modules in container
environment:
- NODE_ENV=development
- VITE_GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID}
- VITE_BACKEND_URL=http://localhost:4002 # Backend API URL
- VITE_GRAFANA_URL=http://localhost:3001 # Grafana URL
tty: true
stdin_open: true
depends_on:
- backend # Ensures API is available first
- grafana # Ensures Grafana is available first
networks:
- queryhawk_monitoring_network
deploy:
resources:
limits:
memory: 512M
# All services share a single bridge network for discovery (e.g., grafana-alloy, loki, mimir).
networks:
queryhawk_monitoring_network:
name: queryhawk_monitoring_network
driver: bridge
# Persistent storage for our services
volumes:
grafana_data: # Dashboard configurations
loki_data: # Loki data
mimir_data: # Mimir data