version: "3"
services:
  server:
    image: postgrest/postgrest
    ports:
      - "3000:3000"
    environment:
      PGRST_DB_URI: postgres://authenticator:mysecretpassword@db:5432/${POSTGRES_DB}
      PGRST_DB_SCHEMAS: api
      PGRST_DB_ANON_ROLE: web_anon
      PGRST_OPENAPI_SERVER_PROXY_URI: http://127.0.0.1:3000
    depends_on:
      - db
  db:
    image: kartoza/postgis:15-3.3
    platform: linux/amd64
    environment:
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASS=${POSTGRES_PASS}
      - POSTGRES_DB=${POSTGRES_DB}
      - ALLOW_IP_RANGE=0.0.0.0/0
      - IGNORE_INIT_HOOK_LOCKFILE=true
    ports:
      - "${POSTGRESTGIS_PORT}:5432"
    volumes:
      - ./setup_db.sql:/docker-entrypoint-initdb.d/setup_db.sql
    healthcheck:
      test: "PGPASSWORD=${POSTGRES_PASS} pg_isready -h 127.0.0.1 -U ${POSTGRES_USER} -d ${POSTGRES_DB}"

networks:
  default:
    name: postgrest-postgis
