-
Notifications
You must be signed in to change notification settings - Fork 311
/
docker-compose.yml
91 lines (79 loc) · 3.14 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
version: '2.1'
volumes:
pg-master-data-dir:
pg-slave-data-dir:
services:
pg-master:
image: 'kartoza/postgis:manual-build'
restart: 'always'
# You can optionally mount to volume, to play with the persistence and
# observe how the slave will behave after restarts.
volumes:
- pg-master-data-dir:/var/lib/postgresql
- ./tests:/tests
environment:
# ALLOW_IP_RANGE option is used to specify additionals allowed domains
# in pg_hba.
# This range should allow slaves to connect to master
ALLOW_IP_RANGE: '0.0.0.0/0'
# We can specify optional credentials
POSTGRES_USER: 'docker'
POSTGRES_PASS: 'docker'
# Setup master replication variables
#PG_MAX_WAL_SENDERS: 8
#PG_WAL_KEEP_SEGMENTS: 100
# You can expose the port to observe it in your local machine
ports:
- "7777:5432"
healthcheck:
test: "exit 0"
pg-slave:
image: 'kartoza/postgis:manual-build'
restart: 'always'
# You can optionally mount to volume, but we're not able to scale it
# in that case.
# The slave will always destroy its database and copy from master at
# runtime
volumes:
- pg-slave-data-dir:/var/lib/postgresql
- ./tests:/tests
environment:
# ALLOW_IP_RANGE option is used to specify additionals allowed domains
# in pg_hba.
# Not really needed in slaves for the replication, but optionally can
# be put when slaves are needed to be a failover server when master
# is down. The IP Range are generally needed if other services wants to
# connect to this slave
ALLOW_IP_RANGE: '0.0.0.0/0'
# REPLICATE_FROM options accepts domain-name or IP address
# with this in mind, you can also put docker service name, because it
# will be resolved as host name.
REPLICATE_FROM: 'pg-master'
# REPLICATE_PORT will default to 5432 if not specified.
# REPLICATE_PORT: '5432'
# In the case where you need to replicate from outside service,
# you can put the server address and port here, as long as the target
# where configured as master, and replicable.
# REPLICATE_FROM: '192.168.1.8'
# REPLICATE_PORT: '7777'
# DESTROY_DATABASE_ON_RESTART will default to True if not specified.
# If specified other than True, it will prevent slave from destroying
# database on restart
DESTROY_DATABASE_ON_RESTART: 'True'
# PROMOTE_MASTER Default empty.
# If specified with any value, then it will convert current slave into
# a writable state. Useful if master is down and the current slave needs
# to be promoted until manual recovery.
# PROMOTE_MASTER: 'True'
# For now we don't support different credentials for replication
# so we use the same credentials as master's superuser, or anything that
# have replication role.
POSTGRES_USER: 'docker'
POSTGRES_PASS: 'docker'
depends_on:
pg-master:
condition: service_healthy
# You can expose the port to observe it in your local machine
# For this sample, it was disabled by default to allow scaling test
ports:
- "7776:5432"