Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
77 lines (74 loc) · 2.34 KB
/
Copy pathdocker-compose.yml
File metadata and controls
77 lines (74 loc) · 2.34 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
# cloud-devops-lab — local three-service monitoring stack
#
# Services:
# app — FastAPI health and metrics service (host port 8000, container port 8000)
# prometheus — metrics scraping (host port 9090, container port 9090)
# grafana — dashboard visualisation (host port 3001, container port 3000)
#
# Usage:
# docker compose up --build
# docker compose down
#
# Access:
# App health: http://localhost:8000/health
# App ready: http://localhost:8000/ready
# App metrics: http://localhost:8000/metrics
# Prometheus: http://localhost:9090
# Grafana: http://localhost:3001 (lab-admin / local-lab-password)
#
# Notes:
# Grafana credentials below are local lab defaults only.
# Override them in .env for any non-local use.
# Do not reuse these values in production.
services:
app:
build: .
container_name: devops-lab-app
ports:
- "${APP_PORT:-8000}:8000"
environment:
- APP_ENV=${APP_ENV:-development}
- APP_LOG_LEVEL=${APP_LOG_LEVEL:-info}
restart: unless-stopped
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import urllib.request; urllib.request.urlopen('http://localhost:8000/health', timeout=3)"
]
interval: 10s
timeout: 5s
retries: 3
start_period: 5s
prometheus:
image: prom/prometheus:v2.52.0
container_name: devops-lab-prometheus
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./monitoring/alert-rules-example.yml:/etc/prometheus/alert-rules-example.yml:ro
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.retention.time=1d"
restart: unless-stopped
depends_on:
app:
condition: service_healthy
grafana:
image: grafana/grafana:10.4.3
container_name: devops-lab-grafana
ports:
- "${GRAFANA_PORT:-3001}:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-lab-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-local-lab-password}
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
- ./monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
restart: unless-stopped
depends_on:
- prometheus