x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  letta:
    <<: *defaults
    image: ${GLOBAL_REGISTRY:-}letta/letta:${LETTA_VERSION:-0.16.7}
    ports:
      - '${LETTA_PORT_OVERRIDE:-8283}:8283'
    volumes:
      - letta_data:/root/.letta
    environment:
      - TZ=${TZ:-UTC}
      - OPENAI_API_KEY=${OPENAI_API_KEY:-}
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
      - GROQ_API_KEY=${GROQ_API_KEY:-}
      - OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-}
    healthcheck:
      test:
        - CMD
        - python3
        - -c
        - "import urllib.request; urllib.request.urlopen('http://localhost:8283/health')"
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 20s
    deploy:
      resources:
        limits:
          cpus: ${LETTA_CPU_LIMIT:-1}
          memory: ${LETTA_MEMORY_LIMIT:-1G}
        reservations:
          cpus: ${LETTA_CPU_RESERVATION:-0.25}
          memory: ${LETTA_MEMORY_RESERVATION:-256M}

volumes:
  letta_data:
