-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathdocker-compose.yml
114 lines (103 loc) · 3.85 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
version: '3.8'
services:
# The Postgres server to store temBoard data.
repository:
image: postgres:14-alpine
ports: [5432:5432]
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
command: [postgres, -c, log_statement=all]
# A mock SMTP server for alterting by mail.
smtp:
image: python:3
ports: [8025:8025]
command: [python3, -m, smtpd, --debug, --nosetuid, --class, DebuggingServer]
# First instance.
postgres0:
image: &postgres_image postgres:14-alpine
# Exposed port is important for docker/dev-switchover.sh
ports: [15432:5432]
environment: &postgres_env
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
PEER_HOST: postgres1
volumes:
- data0:/var/lib/postgresql/data
- run0:/var/run/postgresql
- wal:/var/lib/postgresql/archive/
- ./docker/postgres-ha-entrypoint.sh:/usr/local/bin/postgres-ha-entrypoint.sh
- ./docker/postgres-setup-replication.sh:/docker-entrypoint-initdb.d/setup-replication.sh
- ./share/sql/pg_stat_statements-create-extension.sql:/docker-entrypoint-initdb.d/pg_stat_statements-create-extension.sql
entrypoint: &postgres_entrypoint [/usr/local/bin/postgres-ha-entrypoint.sh]
command: &postgres_command [
postgres,
-c, shared_preload_libraries=pg_stat_statements,
-c, log_statement=all,
-c, "log_line_prefix=%m [%p]: [%l-1] app=%a,db=%d,client=%h,user=%u ",
]
agent0:
image: dalibo/temboard-agent
ports: [2345:2345]
volumes:
- data0:/var/lib/postgresql/data
- run0:/var/run/postgresql
- /var/run/docker.sock:/var/run/docker.sock
- .:/usr/local/src/temboard/
- ./agent/:/usr/local/src/temboard-agent/
links:
- postgres0:postgres0.dev
environment: &agent_env
# Perists bash history. Eases reuse of pip install and hupper command when
# recreating container.
HISTFILE: /usr/local/src/temboard/docker/dev-agent-bash_history
TEMBOARD_HOSTNAME: postgres0.dev
TEMBOARD_LOGGING_LEVEL: DEBUG
TEMBOARD_KEY: key_for_agent
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
command: &agent_command [/usr/bin/tini, sleep, infinity]
# Second instance, with replication of first instance.
postgres1:
image: *postgres_image
environment:
<<: *postgres_env
PEER_HOST: postgres0
# Exposed port is important for docker/dev-switchover.sh
ports: [25432:5432]
volumes:
- data1:/var/lib/postgresql/data
- run1:/var/run/postgresql
- wal:/var/lib/postgresql/archive/
- ./docker/postgres-ha-entrypoint.sh:/usr/local/bin/postgres-ha-entrypoint.sh
- ./docker/postgres-setup-replication.sh:/docker-entrypoint-initdb.d/setup-replication.sh
- ./share/sql/pg_stat_statements-create-extension.sql:/docker-entrypoint-initdb.d/pg_stat_statements-create-extension.sql
entrypoint: *postgres_entrypoint
command: *postgres_command
agent1:
image: dalibo/temboard-agent
ports: [2346:2345]
volumes:
- data1:/var/lib/postgresql/data
- run1:/var/run/postgresql
- /var/run/docker.sock:/var/run/docker.sock
- .:/usr/local/src/temboard/
- ./agent/:/usr/local/src/temboard-agent/
links:
- postgres1:postgres1.dev
environment:
<<: *agent_env
TEMBOARD_HOSTNAME: postgres1.dev
command: *agent_command
volumes:
# 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: