networks:
  DOCKER_NETWORK_DATA: #LIBREPORTAL|DOCKER_NETWORK_TAG|DOCKER_NETWORK_DATA
    external: true

services:
  ollama-webui: #LIBREPORTAL|SERVICE_TAG_1|ollama-webui
    container_name: ollama-webui
    image: ghcr.io/open-webui/open-webui:main
    restart: unless-stopped
    hostname: ollama-open-webui
    ports:
      - "PORTS_DATA_1" #LIBREPORTAL|PORTS_TAG_1|PORTS_DATA_1
    environment:
      - OLLAMA_BASE_URL=http://IP_DATA_1:PORT_INTERNAL_DATA_2 #LIBREPORTAL|IP_TAG_1|IP_DATA_1 #LIBREPORTAL|PORT_INTERNAL_TAG_2|PORT_INTERNAL_DATA_2
      - OLLAMA_API_BASE_URL=http://IP_DATA_1:PORT_INTERNAL_DATA_2 #LIBREPORTAL|IP_TAG_1|IP_DATA_1 #LIBREPORTAL|PORT_INTERNAL_TAG_2|PORT_INTERNAL_DATA_2
    depends_on:
      - ollama-service
    labels:
      libreportal.category: "CATEGORY_DATA" #LIBREPORTAL|CATEGORY_TAG|CATEGORY_DATA
      libreportal.title: "TITLE_DATA" #LIBREPORTAL|TITLE_TAG|TITLE_DATA
      traefik.enable: TRAEFIK_ENABLE_DATA #LIBREPORTAL|TRAEFIK_ENABLE_TAG|TRAEFIK_ENABLE_DATA
      # TRAEFIK_PORT_1_BEGIN
      traefik.http.routers.ollama-webui.entrypoints: web,websecure
      traefik.http.routers.ollama-webui.rule: Host(`DOMAINSUBNAME_DATA_1`) #LIBREPORTAL|DOMAINSUBNAME_TAG_1|DOMAINSUBNAME_DATA_1
      traefik.http.routers.ollama-webui.tls: true
      traefik.http.routers.ollama-webui.tls.certresolver: production
      traefik.http.services.ollama-webui.loadbalancer.server.port: PORT_INTERNAL_DATA_1 #LIBREPORTAL|PORT_INTERNAL_TAG_1|PORT_INTERNAL_DATA_1
      traefik.http.routers.ollama-webui.middlewares: MIDDLEWARE_DATA_1 #LIBREPORTAL|MIDDLEWARE_TAG_1|MIDDLEWARE_DATA_1
      # TRAEFIK_PORT_1_END
    healthcheck:
      disable: HEALTHCHECK_DATA #LIBREPORTAL|HEALTHCHECK_TAG|HEALTHCHECK_DATA
    networks:
      DOCKER_NETWORK_DATA: #LIBREPORTAL|DOCKER_NETWORK_TAG|DOCKER_NETWORK_DATA
        ipv4_address: IP_DATA_1 #LIBREPORTAL|IP_TAG_1|IP_DATA_1

  ollama-service: #LIBREPORTAL|SERVICE_TAG_2|ollama-service
    container_name: ollama-service
    image: ollama/ollama:latest
    restart: unless-stopped
    hostname: ollama
    # GLUETUN_OFF_BEGIN
    ports:
      - "PORTS_DATA_2" #LIBREPORTAL|PORTS_TAG_2|PORTS_DATA_2
    # GLUETUN_OFF_END
    environment:
      - OLLAMA_HOST=0.0.0.0
    volumes:
      - SOCKET_DATA #LIBREPORTAL|SOCKET_TAG|SOCKET_DATA
      - "./data:/root/.ollama"
    healthcheck:
      disable: HEALTHCHECK_DATA #LIBREPORTAL|HEALTHCHECK_TAG|HEALTHCHECK_DATA
    # GLUETUN_OFF_BEGIN
    networks:
      DOCKER_NETWORK_DATA: #LIBREPORTAL|DOCKER_NETWORK_TAG|DOCKER_NETWORK_DATA
        ipv4_address: IP_DATA_2 #LIBREPORTAL|IP_TAG_2|IP_DATA_2
    # GLUETUN_OFF_END
    # GLUETUN_ON_BEGIN
    # network_mode: "container:gluetun-service"
    # GLUETUN_ON_END

  # >>> libreportal-monitoring >>>
  #ollama-exporter:
  #  container_name: ollama-exporter
  #  image: ricardbejarano/ollama-exporter:latest
  #  restart: unless-stopped
  #  depends_on:
  #    - ollama-service
  #  environment:
  #    - OLLAMA_BASE_URL=http://ollama-service:PORT_INTERNAL_DATA_2 #LIBREPORTAL|PORT_INTERNAL_TAG_2|PORT_INTERNAL_DATA_2
  #    - LISTEN=:PORT_INTERNAL_DATA_3 #LIBREPORTAL|PORT_INTERNAL_TAG_3|PORT_INTERNAL_DATA_3
  #  networks:
  #    DOCKER_NETWORK_DATA: #LIBREPORTAL|DOCKER_NETWORK_TAG|DOCKER_NETWORK_DATA
  # <<< libreportal-monitoring <<<
