# AI builder self-host stack — Ollama + Open WebUI + LibreTranslate
# Curl + run:
#   curl -O https://osalt.dev/stack/ai-builder/compose.yml
#   curl -O https://osalt.dev/stack/ai-builder/.env.example && mv .env.example .env
#   docker compose up -d
# After first 'up', pull a model:
#   docker compose exec ollama ollama pull llama3.1:8b
#
# Hardware note: this stack is GPU-bound, not VPS-bound. The Ollama service
# below is configured CPU-only by default — uncomment the `deploy.resources`
# block to expose NVIDIA GPUs (requires nvidia-container-toolkit on host).
#
# Not in this file (per stack editorial):
#   - Continue: it is an IDE extension (VS Code / JetBrains), not a server.
#     Install from the marketplace and point it at http://<this-host>:11434.

services:
  ollama:
    image: ollama/ollama:0.4.7
    restart: unless-stopped
    ports:
      - "${OLLAMA_PORT:-11434}:11434"
    environment:
      OLLAMA_HOST: 0.0.0.0
    volumes:
      - ollama_models:/root/.ollama
    # GPU passthrough — uncomment when running on an NVIDIA box with
    # nvidia-container-toolkit installed:
    # deploy:
    #   resources:
    #     reservations:
    #       devices:
    #         - driver: nvidia
    #           count: all
    #           capabilities: [gpu]

  open-webui:
    image: ghcr.io/open-webui/open-webui:0.5.4
    restart: unless-stopped
    depends_on:
      - ollama
    ports:
      - "${OPEN_WEBUI_PORT:-3010}:8080"
    environment:
      OLLAMA_BASE_URL: http://ollama:11434
      WEBUI_SECRET_KEY: ${OPEN_WEBUI_SECRET_KEY:?set OPEN_WEBUI_SECRET_KEY in .env}
      WEBUI_AUTH: "true"
    volumes:
      - open_webui_data:/app/backend/data

  libretranslate:
    image: libretranslate/libretranslate:v1.6.4
    restart: unless-stopped
    ports:
      - "${LIBRETRANSLATE_PORT:-5000}:5000"
    environment:
      LT_LOAD_ONLY: ${LIBRETRANSLATE_LANGS:-en,es,fr,de,pt,it,nl,ja,zh}
      LT_DISABLE_WEB_UI: "false"
    volumes:
      - libretranslate_models:/home/libretranslate/.local

volumes:
  ollama_models:
  open_webui_data:
  libretranslate_models:
