version: '3.3' services: primary: hostname: 'primary' image: crunchydata/crunchy-postgres:centos7-10.3-1.8.2 secrets: - postgres_primary - postgres_password - postgres_rootpw environment: - PGHOST=/tmp - MAX_CONNECTIONS=10 - MAX_WAL_SENDERS=5 - PG_MODE=primary - PG_PRIMARY_USER=primaryuser - PG_PRIMARY_PASSWORD=postgres_primary - PG_DATABASE=postgres_db - PG_USER=admin - PG_PASSWORD=postgres_password - PG_ROOT_PASSWORD=postgres_rootpw - PG_PRIMARY_PORT=5432 volumes: - pg-primary-vol:/pgdata ports: - '5432' networks: - infra deploy: placement: constraints: - node.labels.type == primary - node.role == worker replica: image: crunchydata/crunchy-postgres:centos7-10.3-1.8.2 secrets: - postgres_primary - postgres_password - postgres_rootpw 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=postgres_primary - PG_DATABASE=postgres_db - PG_USER=admin - PG_PASSWORD=postgres_password - PG_ROOT_PASSWORD=postgres_rootpw volumes: - pg-replica-vol:/pgdata ports: - '5432' networks: - infra deploy: placement: constraints: - node.labels.type != primary - node.role == worker networks: infra: volumes: pg-primary-vol: pg-replica-vol: secrets: postgres_primary: external: true postgres_password: external: true postgres_rootpw: external: true