# DOCKER_HOST=dkhost:2376 docker stack deploy -c docker-compose.yml services
# DOCKER_HOST=dkhost:2376 docker service ps services_postgres

#  CREATE DATABASE yourdbname;
#  CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
#  GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;

version: '3.4'
services:
  postgres:
    volumes:
      - /opt/shared/postgres/data3:/data
    image: library/postgres:12-alpine
    environment:
      POSTGRES_PASSWORD: snqioxni1sw
      POSTGRES_USER: xaicorp_admin
      POSTGRES_DB: xaicorp_default
      PGDATA: /data/xaicorp_pgdata
    ports:
      - 5432:5432

    logging:
      driver: fluentd
      options:
        fluentd-address: "logs.xai-corp.net:24224"
        fluentd-async-connect: 'true'
        tag: postgres

    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: any
        delay: "1s"
        max_attempts: 1
      update_config:
        parallelism: 1
        delay: 2s
        order: start-first
      resources:
        limits:
          cpus: '1'
          memory: 256M

    networks:
      - prod_db


networks:
  prod_db:
    external:
      name: prod_db
