mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
69c238dc95
This is for local testing. Details are in the README. [DSF-218]: https://hasurahq.atlassian.net/browse/DSF-218?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8449 GitOrigin-RevId: 758aa9600fe79ed5c2917def3c86ac185267259e
59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
version: "3"
|
|
|
|
name: hge-postgres-replicas
|
|
|
|
services:
|
|
# The primary server, which supports reads and writes.
|
|
postgres-primary:
|
|
extends:
|
|
service: postgres
|
|
file: ../../../docker-compose/databases.yaml
|
|
command:
|
|
# for some reason this is necessary, even if we don't actually use an archive
|
|
- "--archive_mode=on"
|
|
volumes:
|
|
- primary-data:/var/lib/postgresql/data
|
|
# this script enables replication for all users
|
|
- ./init-primary.sh:/docker-entrypoint-initdb.d/init-primary.sh:ro
|
|
|
|
# Initializes the replica by creating a backup of the primary into the
|
|
# replica's data directory, then marking it as "standby" by creating the
|
|
# "standby.signal" file.
|
|
init-replica:
|
|
extends:
|
|
service: postgres
|
|
file: ../../../docker-compose/databases.yaml
|
|
command:
|
|
- su
|
|
- postgres
|
|
- -c
|
|
- |
|
|
set -ex
|
|
PGPASSWORD=password pg_basebackup --host=postgres-primary --username=postgres --no-password --pgdata=/var/lib/postgresql/data
|
|
touch /var/lib/postgresql/data/standby.signal
|
|
volumes:
|
|
- replica-data:/var/lib/postgresql/data
|
|
depends_on:
|
|
postgres-primary:
|
|
condition: service_healthy
|
|
|
|
# The replica server, which streams writes from the primary, and supports reads.
|
|
postgres-replica:
|
|
extends:
|
|
service: postgres
|
|
file: ../../../docker-compose/databases.yaml
|
|
command:
|
|
- "--primary_conninfo=host=postgres-primary port=5432 user=postgres password=password options='-c wal_sender_timeout=5000'"
|
|
- "--hot_standby=on"
|
|
volumes:
|
|
- replica-data:/var/lib/postgresql/data
|
|
depends_on:
|
|
postgres-primary:
|
|
condition: service_started
|
|
init-replica:
|
|
condition: service_completed_successfully
|
|
|
|
volumes:
|
|
primary-data:
|
|
replica-data:
|