networks:
  1panel-network:
    external: true

services:
  ollama:
    image: ollama/ollama:0.12.6
    container_name: ${CONTAINER_NAME}
    labels:
      createdBy: "Apps"
    restart: always
    networks:
      - 1panel-network
    tty: true
    devices:
      - /dev/dri:/dev/dri
      # - /dev/kfd:/dev/kfd
      # - /dev/nvidia0:/dev/nvidia0
      # - /dev/nvidiactl:/dev/nvidiactl
      # - /dev/nvidia-modeset:/dev/nvidia-modeset
      # - /dev/nvidia-nvswitchctl:/dev/nvidia-nvswitchctl
      # - /dev/nvidia-uvm:/dev/nvidia-uvm
      # - /dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools
      # - /dev/video11:/dev/video11
    ports:
      - ${PANEL_APP_PORT_HTTP}:11434
    env_file:
      - ${GLOBAL_ENV_FILE:-/etc/1panel/envs/global.env}
      - ${ENV_FILE:-/etc/1panel/envs/default.env}
    volumes:
      - ${OLLAMA_ROOT_PATH}/data:/root/.ollama
    environment:
      - TZ=Asia/Shanghai
      - OLLAMA_HOST=0.0.0.0
      - OLLAMA_PORT=11434
      - OLLAMA_MAX_LOADED_MODELS=1
      - OLLAMA_NUM_PARALLEL=1
      - OLLAMA_MAX_QUEUE=512
      - OLLAMA_FLASH_ATTENTION=0
      - OLLAMA_KV_CACHE_TYPE=f16
