version: '3.8'

services:
  searxng:
    image: searxng/searxng:latest
    container_name: ldico-searxng
    restart: unless-stopped
    ports:
      - "8888:8080"
    volumes:
      - ./searxng:/etc/searxng:rw
    environment:
      - SEARXNG_BASE_URL=${SEARXNG_BASE_URL:-http://localhost:8888/}
      - SEARXNG_SECRET_KEY=${SEARXNG_SECRET_KEY}
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    networks:
      - ldico
    depends_on:
      - postgres

  postgres:
    image: pgvector/pgvector:pg16
    container_name: ldico-postgres
    restart: unless-stopped
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_USER=${POSTGRES_USER:-ldico}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - POSTGRES_DB=${POSTGRES_DB:-ldico}
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
    networks:
      - ldico
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-ldico} -d ${POSTGRES_DB:-ldico}"]
      interval: 10s
      timeout: 5s
      retries: 5

networks:
  ldico:
    driver: bridge

volumes:
  postgres_data:
