Created
March 15, 2019 06:40
-
-
Save webchi/a19bfa7e3484baea46b3759643559e1c to your computer and use it in GitHub Desktop.
PG in docker swarm standalone and with replica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.5' | |
networks: | |
webapp: | |
driver: overlay | |
name: webapp | |
services: | |
primary: | |
hostname: 'primary' | |
image: crunchydata/crunchy-postgres:centos7-9.6.11-2.2.0 | |
environment: | |
- PGHOST=/tmp | |
- MAX_CONNECTIONS=10 | |
- MAX_WAL_SENDERS=5 | |
- PG_MODE=primary | |
- PG_PRIMARY_USER=primaryuser | |
- PG_PRIMARY_PASSWORD=primarypassword | |
- PG_DATABASE=testdb | |
- PG_USER=pguser | |
- PG_PASSWORD=pgpassword | |
- PG_ROOT_PASSWORD=longsecretpassword | |
- PG_PRIMARY_PORT=5432 | |
volumes: | |
- pg-primary-vol:/pgdata | |
ports: | |
- "5432" | |
networks: | |
- webapp | |
deploy: | |
restart_policy: | |
condition: on-failure | |
delay: 10s | |
max_attempts: 4 | |
window: 300s | |
healthcheck: | |
test: ["CMD-SHELL", "/usr/pgsql-9.6/bin/pg_isready -U postgres"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
start_period: 2m | |
replica: | |
image: crunchydata/crunchy-postgres:centos7-9.6.11-2.2.0 | |
environment: | |
- PGHOST=/tmp | |
- MAX_CONNECTIONS=10 | |
- MAX_WAL_SENDERS=5 | |
- PG_MODE=replica | |
- PG_PRIMARY_HOST=primary | |
- PG_PRIMARY_PORT=5432 | |
- PG_PRIMARY_USER=primaryuser | |
- PG_PRIMARY_PASSWORD=primarypassword | |
- PG_DATABASE=testdb | |
- PG_USER=testuser | |
- PG_PASSWORD=password | |
- PG_ROOT_PASSWORD=Pje5SXan7qHa9LFL3nmYCUBgwR6EHtF6K4qKnvfd | |
volumes: | |
- pg-replica-vol:/pgdata | |
ports: | |
- "5432" | |
networks: | |
- webapp | |
deploy: | |
restart_policy: | |
condition: on-failure | |
delay: 10s | |
max_attempts: 4 | |
window: 300s | |
healthcheck: | |
test: ["CMD-SHELL", "/usr/pgsql-9.6/bin/pg_isready -U postgres"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
start_period: 30s | |
depends_on: | |
- pg-primary | |
volumes: | |
pg-primary-vol: | |
pg-replica-vol: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.5' | |
networks: | |
webapp: | |
driver: overlay | |
name: webapp | |
services: | |
primary: | |
hostname: 'primary' | |
image: crunchydata/crunchy-postgres:centos7-9.6.11-2.2.0 | |
environment: | |
- PGHOST=/tmp | |
- MAX_CONNECTIONS=10 | |
- MAX_WAL_SENDERS=5 | |
- PG_MODE=primary | |
- PG_PRIMARY_USER=primaryuser | |
- PG_PRIMARY_PASSWORD=primarypassword | |
- PG_DATABASE=testdb | |
- PG_USER=pguser | |
- PG_PASSWORD=pgpassword | |
- PG_ROOT_PASSWORD=longsecretpassword | |
- PG_PRIMARY_PORT=5432 | |
volumes: | |
- pg-primary-vol:/pgdata | |
ports: | |
- "5432" | |
networks: | |
- webapp | |
deploy: | |
restart_policy: | |
condition: on-failure | |
delay: 10s | |
max_attempts: 4 | |
window: 300s | |
healthcheck: | |
test: ["CMD-SHELL", "/usr/pgsql-9.6/bin/pg_isready -U postgres"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
start_period: 2m | |
volumes: | |
pg-primary-vol: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment