services:
  postgres:
    image: pgvector/pgvector:pg16
    container_name: iios-db
    environment:
      POSTGRES_USER: iios
      POSTGRES_PASSWORD: iios
      POSTGRES_DB: iios
    ports:
      - "5434:5432"
    volumes:
      - iios_postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U iios"]
      interval: 5s
      timeout: 5s
      retries: 10

  # Realtime fan-out across replicas (socket.io Redis adapter). Point the service at it
  # with REDIS_URL=redis://localhost:6379; without REDIS_URL the in-memory adapter is used.
  redis:
    image: redis:7-alpine
    container_name: iios-redis
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 10

  # Full-text message search. The service uses it when MEILI_URL is set (else search no-ops).
  # Point the service at it with MEILI_URL=http://localhost:7700 + MEILI_KEY=<master key>.
  meilisearch:
    image: getmeili/meilisearch:v1.11
    container_name: iios-meili
    ports:
      - "7700:7700"
    environment:
      MEILI_NO_ANALYTICS: "true"
      MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-dev-meili-master-key}
    volumes:
      - iios_meili_data:/meili_data
    healthcheck:
      test: ["CMD-SHELL", "curl -sf http://localhost:7700/health || exit 1"]
      interval: 5s
      timeout: 5s
      retries: 10

volumes:
  iios_postgres_data:
  iios_meili_data:
