services:
  owl:
    # Option 1: Use pre-built image from Docker Hub
    image: mugglejinx/owl:latest
    
    # Option 2: Build image locally
    # Uncomment the following lines and comment out the 'image' line above to build locally
    # build:
    #   context: ..
    #   dockerfile: .container/Dockerfile
    
    volumes:
      # Mount .env file for easy API key configuration
      - ../owl/.env:/app/owl/.env
      # Mount examples folder to support running code examples inside the Docker container
      - ../examples:/app/examples
      # Mount data directory
      - ./data:/app/owl/data
      # Mount cache directories to avoid repeated downloads
      - ~/.cache/pip:/root/.pip/cache
      - ~/.cache/playwright:/root/.cache/ms-playwright
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - DISPLAY=:99
      - PYTHONDONTWRITEBYTECODE=1
      - PYTHONUNBUFFERED=1
      - TERM=xterm-256color
      - GRADIO_SERVER_NAME=0.0.0.0
      - GRADIO_SERVER_PORT=7860
      - PYTHONPATH=.
    ports:
      - "7860:7860"
    stdin_open: true
    tty: true
    shm_size: 2gb
    # Simplify resource limits
    deploy:
      resources:
        limits:
          memory: 4G

# Define persistent volumes for caching
volumes:
  playwright-cache:
  pip-cache: