version: '3.7'

services:
  ollama-nvidia:
    image: ollama/ollama:0.1.37
    restart: unless-stopped
    container_name: ollama-nvidia
    ports:
      - '${APP_PORT}:11434'
    networks:
      - tipi_main_network
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities:
                - gpu
    volumes:
      - ${APP_DATA_DIR}/data/.ollama:/root/.ollama
    labels:
      # Main
      traefik.enable: true
      traefik.http.middlewares.ollama-nvidia-web-redirect.redirectscheme.scheme: https
      traefik.http.services.ollama-nvidia.loadbalancer.server.port: 11434
      # Web
      traefik.http.routers.ollama-nvidia-insecure.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.ollama-nvidia-insecure.entrypoints: web
      traefik.http.routers.ollama-nvidia-insecure.service: ollama-nvidia
      traefik.http.routers.ollama-nvidia-insecure.middlewares: ollama-nvidia-web-redirect
      # Websecure
      traefik.http.routers.ollama-nvidia.rule: Host(`${APP_DOMAIN}`)
      traefik.http.routers.ollama-nvidia.entrypoints: websecure
      traefik.http.routers.ollama-nvidia.service: ollama-nvidia
      traefik.http.routers.ollama-nvidia.tls.certresolver: myresolver
      # Local domain
      traefik.http.routers.ollama-nvidia-local-insecure.rule: Host(`ollama-nvidia.${LOCAL_DOMAIN}`)
      traefik.http.routers.ollama-nvidia-local-insecure.entrypoints: web
      traefik.http.routers.ollama-nvidia-local-insecure.service: ollama-nvidia
      traefik.http.routers.ollama-nvidia-local-insecure.middlewares: ollama-nvidia-web-redirect
      # Local domain secure
      traefik.http.routers.ollama-nvidia-local.rule: Host(`ollama-nvidia.${LOCAL_DOMAIN}`)
      traefik.http.routers.ollama-nvidia-local.entrypoints: websecure
      traefik.http.routers.ollama-nvidia-local.service: ollama-nvidia
      traefik.http.routers.ollama-nvidia-local.tls: true
