# PostgreSQL with pg_sift for a laptop or a test environment. From the repository root:
#   docker compose -f packaging/docker/compose.yaml up --build -d
#   docker compose -f packaging/docker/compose.yaml exec db psql -U postgres -d app
# PG_TAG picks the official image tag (17, 18 or 19rc1). PostgreSQL 18 images keep the data directory under /var/lib/postgresql, 17 under
# /var/lib/postgresql/data: for 17 mount the volume there.
services:
  db:
    build:
      context: ../..
      dockerfile: packaging/docker/Dockerfile
      args:
        PG_TAG: ${PG_TAG:-18}
    image: pg_sift:pg${PG_TAG:-18}
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-example}
      POSTGRES_DB: app
    ports:
      - "127.0.0.1:${PG_PORT:-5432}:5432"
    shm_size: 256mb
    volumes:
      - pgdata:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d app"]
      interval: 5s
      timeout: 3s
      retries: 12

volumes:
  pgdata:
