networks:
  r2r-network:
    name: r2r-network

services:
  r2r:
    depends_on:
      postgres:
        condition: service_healthy

  postgres:
    image: pgvector/pgvector:pg16
    environment:
      - POSTGRES_USER=${POSTGRES_USER:-postgres}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
      - POSTGRES_DB=${POSTGRES_DBNAME:-postgres}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - r2r-network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: on-failure

volumes:
  postgres_data:
