version: '3'

services:
  pg-repl:
    image: ucdlib/pg-farm-streaming-replicate:0.0.4
    volumes:
      - pg-data:/var/lib/postgresql/data
      - ./server.crt:/etc/postgres/server.crt
      - ./server.key:/etc/postgres/server.key
    ports:
      - ${PG_FARM_REPL_PORT}:5432
    environment: 
      - PG_MASTER_HOST=${PG_MASTER_HOST}
      - PG_MASTER_PORT=${PG_MASTER_PORT}
      - PG_REP_USER=${PG_REP_USER}
      - PG_REP_PASSWORD=${PG_REP_PASSWORD}

  controller:
    image: ucdlib/pg-farm-controller:0.0.4
    volumes:
      - pg-data:/var/lib/postgresql/data
      - pg-stage:/pg-stage
      - ./.aws-credentials:/root/.aws/credentials
    ports:
      - ${PG_FARM_CONTROLLER_PORT}:3000
    env_file:
        - .env

  pgr:
    image: postgrest/postgrest:v6.0.2
    environment:
      - PGRST_DB_URI=postgres://${PGR_USER_PASSWORD}@pg:5432/postgres
      - PGRST_DB_SCHEMA=${PGR_SCHEMA}
      - PGRST_DB_ANON_ROLE=${PGR_ANON_ROLE}
    depends_on:
      - pg-repl
    ports:
      - ${PG_FARM_PGR_PORT}:3000

volumes:
  pg-data:
    driver: local
  pg-stage:
    driver: local