# Ollama - Local LLM inference
# URL: https://ollama.vishconcord.synology.me
# Port: 11434
# Run large language models locally
version: "3.8"

services:
  ollama:
    container_name: ollama
    image: ollama/ollama:rocm
    restart: unless-stopped
    ports:
      - "11434:11434"
    environment:
      OLLAMA_HOST: 0.0.0.0
      OLLAMA_ORIGINS: https://rxv4access.vishconcord.synology.me
      OLLAMA_OPENAI_COMPAT: 1
      OLLAMA_INSTALL_MODELS: >
        phi3:mini,
        gemma:2b
      OLLAMA_NUM_THREAD: 4
    volumes:
      - /volume2/metadata/docker/ollama/data:/root/.ollama:rw
      - /volume2/metadata/docker/ollama/custom:/models/custom:ro
    healthcheck:
      test: ["CMD", "ollama", "--version"]
      interval: 15s
      timeout: 5s
      retries: 3
      start_period: 45s
    deploy:
      resources:
        limits:
          memory: 18g

  webui:
    container_name: ollama-webui
    image: ghcr.io/open-webui/open-webui:0.6
    restart: unless-stopped
    depends_on:
      ollama:
        condition: service_healthy
    ports:
      - "8271:8080"
    environment:
      OLLAMA_BASE_URL: http://ollama:11434
      WEBUI_SECRET_KEY: "REDACTED_SECRET_KEY"  # pragma: allowlist secret
    volumes:
      - /volume2/metadata/docker/ollama/webui:/app/backend/data:rw
    healthcheck:
      test: timeout 10s bash -c ':> /dev/tcp/127.0.0.1/8080' || exit 1
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 90s
