-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker-compose.replica-postgres.yml
55 lines (51 loc) · 2 KB
/
docker-compose.replica-postgres.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
# This docker compose file contains 2 postgres images that can be used in a master-slave mode.
# postgres-0 is the primary host, this us be the master postgres that is used to write data into the db.
# All written data are synced to the the postgres-1 db, and both images are using repmgr which handles
# switching a slave node to a master one if the primary master goes down.
# So, if postgres-0 goes down, postgres-1 will become the new master and will start accepting to write data
# into the DB. When postgre-1 goes back up it'll be as a slave.
# Images used are from https://github.com/bitnami/bitnami-docker-postgresql-repmgr, more detail there.
version: "3.7"
services:
nginx:
volumes:
- ./docker/nginx/nginx.pg-replica.conf:/etc/nginx/main_config/pg.conf:ro
depends_on:
- postgres-0
childchain:
environment:
DATABASE_URL: postgresql://omisego_dev:omisego_dev@172.27.0.108:5440/engine_repo
postgres-0:
image: bitnami/postgresql-repmgr:12-debian-10
networks:
chain_net:
ipv4_address: 172.27.0.140
environment:
- POSTGRESQL_USERNAME=omisego_dev
- POSTGRESQL_PASSWORD=omisego_dev
- POSTGRESQL_DATABASE=engine_repo
- REPMGR_PASSWORD=omisego_dev
- REPMGR_PRIMARY_HOST=postgres-0
- REPMGR_PRIMARY_PORT=5432
- REPMGR_PARTNER_NODES=postgres-0,postgres-1
- REPMGR_NODE_NAME=postgres-0
- REPMGR_NODE_NETWORK_NAME=postgres-0
- REPMGR_PORT_NUMBER=5432
postgres-1:
image: bitnami/postgresql-repmgr:12-debian-10
networks:
chain_net:
ipv4_address: 172.27.0.130
environment:
- POSTGRESQL_USERNAME=omisego_dev
- POSTGRESQL_PASSWORD=omisego_dev
- POSTGRESQL_DATABASE=engine_repo
- REPMGR_PASSWORD=omisego_dev
- REPMGR_PRIMARY_HOST=postgres-0
- REPMGR_PRIMARY_PORT=5432
- REPMGR_PARTNER_NODES=postgres-0,postgres-1
- REPMGR_NODE_NAME=postgres-1
- REPMGR_NODE_NETWORK_NAME=postgres-1
- REPMGR_PORT_NUMBER=5432
depends_on:
- postgres-0