version: '3'

services:
  pg-repl:
    image: ucdlib/pg-farm-snapshot-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
    env_file:
        - .env

  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
    env_file:
      - .env
    environment:
      - PGRST_DB_URI=postgres://${PGR_USER_PASSWORD}@pg-repl:5432/${PGR_DATABASE}
      - 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