version: "3.7"

networks:
  mother:
    external: true


services:
  mongo1:
    image: registry.vnfco.ir/library/bitnami/mongodb:4.4.11-debian-10-r5
    volumes:
      - /volume/mongo/primary:/bitnami/mongodb
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongoprimary
      - MONGODB_ROOT_PASSWORD=cWv1WQvWEp+LPdax9WeM6PeT7KgyTE9zKmC5y1ieqz4JtpLiVifJrQg0VHYhE6l
    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.5'
          memory: 350M
      replicas: 1
      mode: replicated
      placement:
        constraints:
          - node.role == worker
    ports:
      - "27011:27017"
    networks:
      - mother
#REDIS
  redis:
    image: registry.vnfco.ir/library/redis:primary
    deploy:
      placement:
        constraints:
          - node.role==worker
      resources:
        limits:
          cpus: '0.30'
          memory: 20M
      update_config:
        parallelism: 1
        delay: 10s
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 10
        window: 120s
    networks:
      - mother
    volumes:
      - /volume/redis:/data
    ports:
      - "6969:6379"

# RABBIT
  rabbit:
    image: registry.vnfco.ir/library/rabbitmq:3.8.19-management-alpine
    deploy:
      placement:
        constraints:
          - node.role==worker
      resources:
        reservations:
          cpus: '0.25'
          memory: 100M
      restart_policy:
        condition: any
        delay: 10s
        max_attempts: 5
    environment:
      - RABBITMQ_DEFAULT_PASS=22102210aA
      - RABBITMQ_DEFAULT_USER=MyNameIsAdmin
    networks:
      - mother
    ports:
      - "5672:5672"
      - "15672:15672"
  pg:
    image: registry.vnfco.ir/library/bitnami/postgresql:12
    deploy:
      placement:
        constraints:
          - node.role==worker
      update_config:
        parallelism: 1
        delay: 10s
        order: stop-first
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 10
        window: 120s
    environment:
      - POSTGRESQL_USERNAME=igarsonAgent
      - POSTGRESQL_PASSWORD=aXysDgz7Nfr55dT5VEXmTDoqsUOG/gl4kmEe6QD/oqwna95RiYXrAyy8
      - POSTGRESQL_DATABASE=igarsonDB
    networks:
      - mother
    volumes:
      - /volume/postgres:/bitnami/postgresql
    ports:
      - "5431:5432"