-
Notifications
You must be signed in to change notification settings - Fork 54
/
docker-compose.yml
245 lines (226 loc) · 7.97 KB
/
docker-compose.yml
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
version: '3.8'
# For consistency, each service stanza a configured in order : data (image,
# volumes, etc.), network and process (user, env, command, etc.).
services:
# The Postgres server to store temBoard data.
repository:
image: postgres:17-alpine
ports: ["5432:5432"]
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
command: [
postgres,
-c, log_statement=all,
-c, log_connections=on,
-c, "log_line_prefix=%m [%p]: [%l-1] user=%u,client=%h,db=%d,app=%a ",
-c, cluster_name=repository,
]
# A mock SMTP server for alterting by mail.
smtp:
image: mailhog/mailhog
ports:
- 1025:1025
- 8025:8025
# First instance.
postgres0:
image: &postgres_image postgres:17-alpine
volumes:
- data0:/var/lib/postgresql/data
- run0:/var/run/postgresql
- wal:/var/lib/postgresql/archive/
- ./dev/postgres-ha-entrypoint.sh:/usr/local/bin/postgres-ha-entrypoint.sh
- ./dev/postgres-setup-replication.sh:/docker-entrypoint-initdb.d/setup-replication.sh
- ./ui/share/sql/pg_stat_statements-create-extension.sql:/docker-entrypoint-initdb.d/pg_stat_statements-create-extension.sql
networks:
default:
aliases:
- postgres0.dev
# Exposed port is important for dev/bin/switchover.sh
ports: [15432:5432]
environment: &postgres_env
POSTGRES_INITDB_ARGS: "--data-checksums"
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
PEER_HOST: postgres1
entrypoint: &postgres_entrypoint [/usr/local/bin/postgres-ha-entrypoint.sh]
command: [
postgres,
-c, shared_preload_libraries=pg_stat_statements,
-c, log_connections=on,
-c, log_statement=all,
-c, "log_line_prefix=%m [%p]: [%l-1] app=%a,db=%d,client=%h,user=%u ",
-c, cluster_name=postgres0,
]
agent0:
image: dalibo/temboard-agent:dev
build: &build-agent
args: [http_proxy]
context: agent/
dockerfile: packaging/docker/Dockerfile.dev
volumes:
- data0:/var/lib/postgresql/data
- run0:/var/run/postgresql
- /var/run/docker.sock:/var/run/docker.sock
- ./:/usr/local/src/temboard/
ports: [2345:2345]
environment: &agent_env
# Persists bash history. Eases reuse of hupper command when recreating
# container.
HISTFILE: /usr/local/src/temboard/dev/agent-bash_history
PGUSER: postgres
PSQL_HISTORY: /usr/local/src/temboard/dev/agent-psql_history
# Send TEMBOARD_UI_URL from .env file
TEMBOARD_UI_URL: "${TEMBOARD_UI_URL-}"
TEMBOARD_UI_USER: admin
TEMBOARD_UI_PASSWORD: admin
TEMBOARD_HOSTNAME: postgres0.dev
TEMBOARD_LOGGING_LEVEL: DEBUG
TEMBOARD_SSL_CA: /usr/local/src/temboard/agent/share/temboard-agent_ca_certs_CHANGEME.pem
TEMBOARD_SSL_CERT: /usr/local/src/temboard/agent/share/temboard-agent_CHANGEME.pem
TEMBOARD_SSL_KEY: /usr/local/src/temboard/agent/share/temboard-agent_CHANGEME.key
# Actually, entrypoint set TEMBOARD_CONFIGFILE, but not for docker compose exec
TEMBOARD_CONFIGFILE: /etc/temboard-agent/postgres0/temboard-agent.conf
entrypoint: &agent_entrypoint [/usr/bin/tini, /usr/local/src/temboard/dev/agent-entrypoint.sh]
command: &agent_command [sleep, infinity]
# Second instance, with replication of first instance.
postgres1:
image: *postgres_image
volumes:
- data1:/var/lib/postgresql/data
- run1:/var/run/postgresql
- wal:/var/lib/postgresql/archive/
- ./dev/postgres-ha-entrypoint.sh:/usr/local/bin/postgres-ha-entrypoint.sh
- ./dev/postgres-setup-replication.sh:/docker-entrypoint-initdb.d/setup-replication.sh
- ./ui/share/sql/pg_stat_statements-create-extension.sql:/docker-entrypoint-initdb.d/pg_stat_statements-create-extension.sql
# Exposed port is important for dev/bin/switchover.sh
networks:
default:
aliases:
- postgres1.dev
ports: [25432:5432]
environment:
<<: *postgres_env
PEER_HOST: postgres0
entrypoint: *postgres_entrypoint
command: [
postgres,
-c, shared_preload_libraries=pg_stat_statements,
-c, log_connections=on,
-c, log_statement=all,
-c, "log_line_prefix=%m [%p]: [%l-1] app=%a,db=%d,client=%h,user=%u ",
-c, cluster_name=postgres1,
]
agent1:
image: dalibo/temboard-agent:dev
build:
<<: *build-agent
volumes:
- data1:/var/lib/postgresql/data
- run1:/var/run/postgresql
- /var/run/docker.sock:/var/run/docker.sock
- ./:/usr/local/src/temboard/
ports: [2346:2345]
environment:
<<: *agent_env
TEMBOARD_CONFIGFILE: /etc/temboard-agent/postgres1/temboard-agent.conf
TEMBOARD_HOSTNAME: postgres1.dev
entrypoint: *agent_entrypoint
command: *agent_command
selenium:
image: selenium/standalone-firefox@sha256:b6d8279268b3183d0d33e667e82fec1824298902f77718764076de763673124f
ports:
- "4444:4444"
- "7900:7900"
environment:
# Let webdriver server keep session opened for two hours. This way,
# selenium does not close a session while pdb is waiting.
SE_NODE_SESSION_TIMEOUT: 7200
VNC_NO_PASSWORD: "y"
TZ: Europe/Paris
# 1280x768 is common and fit in noVNC page.
SCREEN_WIDTH: 1280
SCREEN_HEIGHT: 768
# An old instance for last stable temBoard agent.
postgres-stable:
image: postgres:9.6-alpine
volumes:
- data-stable:/var/lib/postgresql/data
- run-stable:/var/run/postgresql
- wal:/var/lib/postgresql/archive/
- ./ui/share/sql/pg_stat_statements-create-extension.sql:/docker-entrypoint-initdb.d/pg_stat_statements-create-extension.sql
healthcheck:
test: ["CMD-SHELL", "psql -h localhost -U postgres -c \"SELECT 'HAS_STATEMENTS' FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'pg_stat_statements';\""]
interval: 2s
timeout: 2s
retries: 5
networks:
default:
aliases:
- postgres-stable.dev
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
command: [
postgres,
-c, shared_preload_libraries=pg_stat_statements,
-c, log_connections=on,
-c, log_statement=all,
-c, "log_line_prefix=%m [%p]: [%l-1] app=%a,db=%d,client=%h,user=%u ",
-c, cluster_name=postgres-stable,
]
agent-stable:
image: dalibo/temboard-agent:8
volumes:
- data-stable:/var/lib/postgresql/data
- run-stable:/var/run/postgresql
- /var/run/docker.sock:/var/run/docker.sock
ports: [2347:2345]
depends_on:
postgres-stable:
condition: service_healthy
environment:
TEMBOARD_HOSTNAME: postgres-stable.dev
TEMBOARD_LOGGING_LEVEL: DEBUG
TEMBOARD_UI_URL: "${TEMBOARD_UI_URL-}"
grafana:
image: grafana/grafana:9.0.2
volumes:
- grafana-data:/var/lib/grafana
- ./dev/grafana/entrypoint.sh:/usr/local/sbin/grafana-entrypoint.sh
- ./dev/grafana/rootfs:/usr/local/lib/grafana/rootfs
entrypoint: [/usr/local/sbin/grafana-entrypoint.sh]
ports: ["3000:3000"]
user: root
loki:
image: grafana/loki:2.6.0
command: -config.file=/etc/loki/local-config.yaml
ports: ["3100:3100"]
prometheus:
image: prom/prometheus:v2.36.2
volumes:
- ./dev/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./dev/prometheus/import:/import
- ./dev/prometheus/targets:/targets
ports:
- 9090:9090
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--web.console.libraries=/usr/share/prometheus/console_libraries"
- "--web.console.templates=/usr/share/prometheus/consoles"
- --log.level=debug
volumes:
grafana-data:
# Shared archive volume between replicated instances.
wal:
# data_directory for first postgres instance.
data0:
# /run/postgresql to share socket between postgres instance and agent.
run0:
# data directory for second postgres instances.
data1:
# /run/postgresql to share socket between postgres instance and agent.
run1:
data-stable:
run-stable: