
version: "3.7"

networks:
  mother:
    external: true



  
services:
  pgmaster:
    image: registry.vnfco.ir/library/bitnami/postgresql:13
    volumes:
        - '/volume/pg:/bitnami/postgresql'
    environment:
      - POSTGRESQL_USERNAME=igarsonAgent
      - POSTGRESQL_PASSWORD=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6
      - POSTGRESQL_DATABASE=igarsonDB
      - POSTGRESQL_REPLICATION_MODE=master
      - POSTGRESQL_REPLICATION_USER=pgreplicator
      - POSTGRESQL_REPLICATION_PASSWORD=ciXz6xmnEMZSO+0T8L6mGcFJrAvPzkTC04oh/WYIRi51gMQLPfW8tTEHALX6fhk4
    deploy:
      update_config:
        parallelism: 1
        delay: 10s
        order: start-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s 
      resources:
        limits:
          cpus: '0.7'
          memory: 500M
      replicas: 1
      mode: replicated
      placement:
        constraints:
          - node.labels.mongo.replica == 1
    ports:
      - 5432
    networks:
      - mother
      

  pgslave1:
    image: registry.vnfco.ir/library/bitnami/postgresql:13  
    environment:
      - POSTGRESQL_REPLICATION_MODE=slave
      - POSTGRESQL_REPLICATION_USER=pgreplicator
      - POSTGRESQL_REPLICATION_PASSWORD=ciXz6xmnEMZSO+0T8L6mGcFJrAvPzkTC04oh/WYIRi51gMQLPfW8tTEHALX6fhk4
      - POSTGRESQL_MASTER_HOST=pgmaster
      - POSTGRESQL_PASSWORD=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6
      - POSTGRESQL_MASTER_PORT_NUMBER=5432

    deploy:
      update_config:
        parallelism: 1
        delay: 10s
        order: start-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s 
      resources:
        limits:
          cpus: '0.3'
          memory: 300M
      mode: replicated
      replicas: 1
      placement:
        constraints: 
            - node.labels.mongo.replica == 2
    ports:
      - 5432
    networks:
      - mother





