services:
  monitor:
    image: citusdata/pg_auto_failover:demo
    environment:
      PGDATA: /tmp/pgaf
      PG_AUTOCTL_DEBUG: 1
    command: pg_autoctl create monitor --ssl-self-signed --auth trust --run
    expose:
      - 5432
  node1:
    image: citusdata/pg_auto_failover:demo
    environment:
      PGDATA: /tmp/pgaf
      PGUSER: ad
      PGDATABASE: analytics
      PG_AUTOCTL_MONITOR: "postgresql://autoctl_node@monitor/pg_auto_failover"
    command:  pg_autoctl create postgres --ssl-self-signed --auth trust --pg-hba-lan --run
    expose:
      - 5432
  node2:
    image: citusdata/pg_auto_failover:demo
    environment:
      PGDATA: /tmp/pgaf
      PGUSER: ad
      PGDATABASE: analytics
      PG_AUTOCTL_MONITOR: "postgresql://autoctl_node@monitor/pg_auto_failover"
    command:  pg_autoctl create postgres --ssl-self-signed --auth trust --pg-hba-lan --run
    expose:
      - 5432
  node3:
    image: citusdata/pg_auto_failover:demo
    environment:
      PGDATA: /tmp/pgaf
      PGUSER: ad
      PGDATABASE: analytics
      PG_AUTOCTL_MONITOR: "postgresql://autoctl_node@monitor/pg_auto_failover"
    command:  pg_autoctl create postgres --ssl-self-signed --auth trust --pg-hba-lan --run
    expose:
      - 5432
  demo-app:
    image: citusdata/pg_auto_failover:demo
    environment:
      PGDATA: /tmp/pgaf
      PGUSER: ad
      PGDATABASE: analytics
      PG_AUTOCTL_MONITOR: "postgresql://autoctl_node@monitor/pg_auto_failover"
      PG_AUTOCTL_DEMO_CLIENTS: 10
      PG_AUTOCTL_DEMO_DURATION: 125
      PG_AUTOCTL_DEMO_FAILOVER_FREQ: 30
      PG_AUTOCTL_DEMO_FAILOVER_FIRST: 45
    command:  pg_autoctl do demo run
