-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
88 lines (82 loc) · 2.21 KB
/
Copy pathdocker-compose.yml
File metadata and controls
88 lines (82 loc) · 2.21 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
version: "3.8"
# REDIS_PASSWORD must be set in the shell or a .env file before starting.
# Example: export REDIS_PASSWORD=supersecret && docker compose up -d
services:
redis:
image: redis:7-alpine
ports:
- "127.0.0.1:6379:6379" # bind to loopback only — not exposed to LAN/internet
command: >
redis-server
--maxmemory 256mb
--maxmemory-policy allkeys-lru
--requirepass ${REDIS_PASSWORD:?REDIS_PASSWORD env var is required}
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 5s
timeout: 3s
retries: 5
rate-limiter:
build:
context: .
dockerfile: Dockerfile.server
ports:
- "50051:50051"
- "9090:9090"
environment:
- REDIS_ADDR=redis:6379
- REDIS_PASSWORD=${REDIS_PASSWORD}
- GRPC_PORT=50051
- METRICS_PORT=9090
- RATE_LIMIT=100
- TLS_CERT=/certs/server.crt
- TLS_KEY=/certs/server.key
volumes:
- ./certs:/certs:ro
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:9090/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
gateway:
build:
context: .
dockerfile: Dockerfile.gateway
ports:
- "8081:8081"
environment:
- GRPC_ADDRS=rate-limiter:50051
- HTTP_PORT=8081
- UPSTREAM_URL=http://httpbin.org
- METRICS_ADDR=http://rate-limiter:9090
- TLS_CERT=/certs/server.crt
volumes:
- ./certs:/certs:ro
depends_on:
rate-limiter:
condition: service_healthy # wait until gRPC + metrics are ready
prometheus:
image: prom/prometheus:latest
ports:
- "9091:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
depends_on:
rate-limiter:
condition: service_healthy
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
depends_on:
- prometheus