services:
  postgres:
    image: pgvector/pgvector:pg17
    environment:
      POSTGRES_DB: brain
      POSTGRES_USER: brain
      POSTGRES_PASSWORD: ${BRAIN_DB_PASSWORD}
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U brain -d brain"]
      interval: 10s
      timeout: 5s
      retries: 5

  aide:
    image: gitlab.pm/rune/oai-web:latest
    ports:
      - "${PORT:-8080}:8080"
    environment:
      TZ: Europe/Oslo
    volumes:
      - ./data:/app/data      # Encrypted database and logs
      - ./SOUL.md:/app/SOUL.md:ro   # Agent personality
      - ./USER.md:/app/USER.md:ro   # Owner context
    env_file:
      - .env
    depends_on:
      postgres:
        condition: service_healthy
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 5s
      retries: 3
