# Hermetic test database for the EDR passenger E2E harness.
# Isolated from any dev/prod Postgres: distinct container name + non-standard host port (5544).
# Single database `edr_database` with schemas `passenger`, `iam`, `edr_payment` (see init/01-schemas.sql).
services:
  postgres-e2e:
    image: postgres:17
    container_name: edr-passenger-e2e-db
    environment:
      POSTGRES_USER: edr
      POSTGRES_PASSWORD: edr_secret
      POSTGRES_DB: edr_database
    ports:
      - "5544:5432"
    volumes:
      - ./init:/docker-entrypoint-initdb.d:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U edr -d edr_database"]
      interval: 3s
      timeout: 3s
      retries: 20
    tmpfs:
      # Ephemeral storage — every `docker compose down` wipes the DB. Nothing to clean up.
      - /var/lib/postgresql/data

  # Broker for the passenger-api payment-events consumer (golevelup RabbitMQ). The API blocks boot
  # until this connects. Pre-creates the `payment` vhost that PAYMENT_RABBITMQ_URL points at.
  rabbitmq-e2e:
    image: rabbitmq:3-management
    container_name: edr-passenger-e2e-rmq
    environment:
      RABBITMQ_DEFAULT_USER: edr
      RABBITMQ_DEFAULT_PASS: edr_secret
      RABBITMQ_DEFAULT_VHOST: payment
    ports:
      - "5672:5672"
      - "15672:15672"
    healthcheck:
      test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
      interval: 5s
      timeout: 5s
      retries: 20
