-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
173 lines (163 loc) · 4.64 KB
/
Copy pathdocker-compose.yml
File metadata and controls
173 lines (163 loc) · 4.64 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
# ReadIssue overload-simulation lab.
# Built up across tasks; this revision covers Postgres + seeder (Task 1).
name: readissue
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- ./db/init:/docker-entrypoint-initdb.d:ro
- pgdata:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 2s
timeout: 3s
retries: 30
networks:
- lab
# Read replica: an independent read-only Postgres copy. Because the dataset
# is static after seeding, an identically-seeded copy behaves like a read
# replica for the purpose of spreading read load.
replica:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- ./db/init:/docker-entrypoint-initdb.d:ro
- pgdata_replica:/var/lib/postgresql/data
ports:
- "5433:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 2s
timeout: 3s
retries: 30
networks:
- lab
seeder:
build: ./seeder
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_HOST: ${POSTGRES_HOST}
POSTGRES_PORT: ${POSTGRES_PORT}
SEED_ROWS: ${SEED_ROWS}
depends_on:
postgres:
condition: service_healthy
networks:
- lab
restart: "no"
redis:
image: redis:7-alpine
command: ["redis-server", "--save", "", "--maxmemory", "256mb", "--maxmemory-policy", "allkeys-lru"]
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 3s
timeout: 3s
retries: 10
networks:
- lab
pgbouncer:
image: edoburu/pgbouncer:v1.25.2-p0
environment:
DB_HOST: postgres
DB_PORT: "5432"
DB_USER: ${POSTGRES_USER}
DB_PASSWORD: ${POSTGRES_PASSWORD}
DB_NAME: ${POSTGRES_DB}
LISTEN_PORT: "6432"
AUTH_TYPE: scram-sha-256
POOL_MODE: transaction
MAX_CLIENT_CONN: "1000"
DEFAULT_POOL_SIZE: "20"
ADMIN_USERS: ${POSTGRES_USER}
depends_on:
postgres:
condition: service_healthy
networks:
- lab
traefik:
# NOTE: the local Docker daemon is very new (min API 1.40). Traefik <= v3.3
# pins Docker client API 1.24 and fails discovery against it; v3.7 negotiates
# a modern API version correctly, so this version floor matters.
image: traefik:v3.7
command:
# Docker provider: auto-discover containers by label.
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=${LAB_NETWORK}
# Ingress entrypoint used by the worker routers (entrypoints.web).
- --entrypoints.web.address=:80
# Insecure dashboard/API for the local lab.
- --api.dashboard=true
- --api.insecure=true
- --ping=true
- --accesslog=false
- --log.level=INFO
ports:
- "${TRAEFIK_ENTRYPOINT_PORT}:80" # load-balanced ingress -> workers
- "${TRAEFIK_DASHBOARD_PORT}:8080" # Traefik dashboard/API
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
healthcheck:
test: ["CMD", "traefik", "healthcheck", "--ping"]
interval: 5s
timeout: 3s
retries: 10
networks:
- lab
control-plane:
build: ./control-plane
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_HOST: postgres
POSTGRES_PORT: ${POSTGRES_PORT}
COLLECTOR_PG_HOST: postgres
REDIS_HOST: redis
REDIS_PORT: ${REDIS_PORT}
INGRESS_URL: http://traefik:80
WORKER_IMAGE: ${WORKER_IMAGE}
LAB_NETWORK: ${LAB_NETWORK}
MAX_WORKERS: ${MAX_WORKERS}
LOADGEN_PROCS: ${LOADGEN_PROCS:-8}
volumes:
# Needed to spawn/destroy worker containers on the lab network.
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "${CONTROL_PLANE_PORT}:8000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
traefik:
condition: service_started
networks:
- lab
frontend:
build: ./frontend
ports:
- "3000:80"
depends_on:
- control-plane
networks:
- lab
volumes:
pgdata:
pgdata_replica:
networks:
lab:
name: ${LAB_NETWORK}