services:
  neomem-postgres:
    image: ankane/pgvector:v0.5.1
    container_name: neomem-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: neomem
      POSTGRES_PASSWORD: neomempass
      POSTGRES_DB: neomem
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U neomem -d neomem || exit 1"]
      interval: 5s
      timeout: 5s
      retries: 10
    networks:
      - lyra-net

  neomem-neo4j:
    image: neo4j:5
    container_name: neomem-neo4j
    restart: unless-stopped
    environment:
      NEO4J_AUTH: neo4j/neomemgraph
    ports:
      - "7474:7474"
      - "7687:7687"
    volumes:
      - neo4j_data:/data
    healthcheck:
      test: ["CMD-SHELL", "cypher-shell -u neo4j -p neomemgraph 'RETURN 1' || exit 1"]
      interval: 10s
      timeout: 10s
      retries: 10
    networks:
      - lyra-net

  neomem-api:
    build: .
    image: lyra-neomem:latest
    container_name: neomem-api
    restart: unless-stopped
    ports:
      - "7077:7077"
    env_file:
      - .env
    volumes:
      - ./neomem_history:/app/history
    depends_on:
      neomem-postgres:
        condition: service_healthy
      neomem-neo4j:
        condition: service_healthy
    networks:
      - lyra-net

volumes:
  postgres_data:
  neo4j_data:

networks:
  lyra-net:
    external: true