<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    部署docker版的人工智能OPEN-WEBUI+OLLAMA+NGINX

    一鍵部署人工智能中的OPEN-WEBUI,OLLAMA, NGINX,也就對類似OPEN-AI的對話機器人
    docker-compose.yaml
    services:

      # ollama:
      #   deploy:
      #     resources:
      #       reservations:
      #         devices:
      #           - driver: nvidia
      #             count: all
      #             capabilities:
      #               - gpu  #使用GPU加速
      #   volumes:
      #     - ollama-volume:/root/.ollama #配置OLLAMA的配置數據文件在宿主機
      #     - /etc/localtime:/etc/localtime:ro
      #   container_name: ollama
      #   image: ollama/ollama
      #   restart: unless-stopped
      #   networks:
      #     - isolated #使用DOCKER的隔離網絡
      #     - internet

      vllm:
        container_name: vllm
        image: vllm/vllm-openai:latest
        # ipc: host
        volumes:
          - ${HUGGINGFACE_MODELS_DIR}:/models
          - /etc/localtime:/etc/localtime:ro
        command: >
          --model /models/models--unsloth--llama-3-8b-Instruct-lawdata
          --served-model-name llama-3-8b-Instruct-lawdata
          --gpu-memory-utilization 0.90
          --max_model_len 1072
          --quantization bitsandbytes
          --load_format bitsandbytes
        ports:
          - "8000:8000"
        deploy:
          resources:
            reservations:
              devices:
                - driver: nvidia
                  count: all
                  capabilities: [gpu]
        networks:
          - isolated #使用DOCKER的隔離網絡

      # https://github.com/open-webui/open-webui
      open-webui: #全局維一的服務名
        volumes:
          - open-webui-volume:/app/backend/data #配置open-webui的配置數據文件在宿主機
          - /etc/localtime:/etc/localtime:ro
        container_name: open-webui
        restart: unless-stopped
        image: ghcr.io/open-webui/open-webui:main
        # network_mode: host
        ports:
          - "3000:3000"
        environment:
          # - OLLAMA_BASE_URL=http://ollama:11434 #OPEN-WEBUI訪問OLLAMA的地址,其實就是服務名代替IP
          - ENABLE_OLLAMA_API=False
          - OPENAI_API_BASE_URL=http://vllm:8000 /v1
          - /etc/localtime:/etc/localtime:ro
          - LOG_LEVEL=DEBUG
        depends_on:
          # - ollama
          - vllm
        networks:
          - isolated

      nginx-webui:
        volumes:
          - ${NGINX_DATA_DIR}/html:/usr/share/nginx/html:ro
          - ${NGINX_DATA_DIR}/conf/nginx.conf:/etc/nginx/nginx.conf:ro
          - ${NGINX_DATA_DIR}/conf/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro
          - ${NGINX_DATA_DIR}/conf/.htpasswd:/etc/nginx/.htpasswd:ro
          - /etc/localtime:/etc/localtime:ro
          - ${NGINX_DATA_DIR}/log/access.log:/var/log/nginx/access.log
          - ${NGINX_DATA_DIR}/log/error.log:/var/log/nginx/error.log
        container_name: nginx-webui
        ports:
          - "81:81"
        image: nginx:latest
        #image: quay.io/ricardbejarano/nginx
        depends_on:
          - open-webui
        restart: unless-stopped
        networks:
          - isolated
          - internet

    volumes:
      ollama-volume:
        driver: local
        driver_opts:
          type: none
          o: bind
          device: ${OLLAMA_DATA_DIR}
      open-webui-volume:
        driver: local
        driver_opts:
          type: none
          o: bind
          device: ${OPEN_WEBUI_DATA_DIR}

    networks:
      isolated:
        driver: bridge
        internal: true
      internet:
        driver: bridge

    nginx.conf
    user  nginx;
    worker_processes  auto;

    error_log  /var/log/nginx/error.log warn;
    pid        /var/run/nginx.pid;

    events {
        worker_connections  1024;
    }

    http {
        include       /etc/nginx/mime.types;
        default_type  application/octet-stream;

        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';

        access_log  /var/log/nginx/access.log  main;

        sendfile        on;
        keepalive_timeout  65;

        include /etc/nginx/conf.d/*.conf;  # 加載 conf.d 目錄下的配置文件
    }

    docker/docker-nginx/data/conf/conf.d/default.conf
    # server {
    #     listen       80;
    #     server_name  example.com www.example.com;

    #     root   /usr/share/nginx/html;
    #     index  index.html index.htm;

    #     location / {
    #         try_files $uri $uri/ =404;
    #     }

    #     error_page   500 502 503 504  /50x.html;
    #     location = /50x.html {
    #         root   /usr/share/nginx/html;
    #     }
    # }
    server {
        listen 81;
        server_name localhost;

        location / {
            proxy_pass http://open-webui:8080;
            # proxy_pass http://localhost:8080;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        # 代理 WebSocket 請求
        location /ws/ {
            proxy_pass http://open-webui:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
    }

    00_varible.sh
    #!/bin/bash

    # 獲取當前腳本的路徑
    # SCRIPT_PATH="$(realpath "$0")"
    # echo "當前腳本的路徑是: $SCRIPT_PATH"

    # 獲取當前腳本所在的目錄
    # SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
    # echo "當前腳本所在的目錄是: $SCRIPT_DIR"
    # cd $SCRIPT_DIR

    # export HTTP_PROXY=http://192.168.0.102:7890
    # export HTTPS_PROXY=https://192.168.0.102:7890


    export DOCKER_ROOT_DIR=/home/paul/paulwong/work/workspaces/python-ai-project/docker
    export NGINX_DATA_DIR=${DOCKER_ROOT_DIR}/docker-nginx/data
    export OLLAMA_DATA_DIR=${DOCKER_ROOT_DIR}/docker-ollama/data
    export OPEN_WEBUI_DATA_DIR=${DOCKER_ROOT_DIR}/docker-webui/data
    export HUGGINGFACE_MODELS_DIR=/home/paul/.cache/huggingface/models

    01_start-nginx-ollama-webui.sh
    #!/bin/bash

    # 獲取當前腳本的路徑
    SCRIPT_PATH="$(realpath "$0")"
    echo "當前腳本的路徑是: $SCRIPT_PATH"

    # 獲取當前腳本所在的目錄
    SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
    echo "當前腳本所在的目錄是: $SCRIPT_DIR"
    cd $SCRIPT_DIR

    source ./00_varible.sh
    docker compose -f configs/docker-compose.yaml down
    docker compose -f configs/docker-compose.yaml up

    02_restart-nginx-ollama-webui.sh
    #!/bin/bash

    # 獲取當前腳本的路徑
    SCRIPT_PATH="$(realpath "$0")"
    echo "當前腳本的路徑是: $SCRIPT_PATH"

    # 獲取當前腳本所在的目錄
    SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
    echo "當前腳本所在的目錄是: $SCRIPT_DIR"
    cd $SCRIPT_DIR

    source ./00_varible.sh
    docker compose -f configs/docker-compose.yaml restart

    03_login_ollama.sh
    #!/bin/bash

    # 獲取當前腳本的路徑
    SCRIPT_PATH="$(realpath "$0")"
    echo "當前腳本的路徑是: $SCRIPT_PATH"

    # 獲取當前腳本所在的目錄
    SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
    echo "當前腳本所在的目錄是: $SCRIPT_DIR"
    cd $SCRIPT_DIR

    source ./00_varible.sh
    docker compose -f configs/docker-compose.yaml exec ollama /bin/bash
    # echo ${DOCKER_ROOT_DIR}

    04_restart_open_webui.sh
    #!/bin/bash

    # 獲取當前腳本的路徑
    SCRIPT_PATH="$(realpath "$0")"
    echo "當前腳本的路徑是: $SCRIPT_PATH"

    # 獲取當前腳本所在的目錄
    SCRIPT_DIR="$(dirname "$SCRIPT_PATH")"
    echo "當前腳本所在的目錄是: $SCRIPT_DIR"
    cd $SCRIPT_DIR

    source ./00_varible.sh
    docker compose -f configs/docker-compose.yaml restart open-webui
    # echo ${DOCKER_ROOT_DIR}

    posted on 2024-06-19 22:23 paulwong 閱讀(200) 評論(0)  編輯  收藏 所屬分類: AI-LLM

    主站蜘蛛池模板: 亚洲中文字幕无码久久| 毛茸茸bbw亚洲人| 在线电影你懂的亚洲| 99精品全国免费观看视频..| 又粗又黄又猛又爽大片免费| 亚洲AV网一区二区三区| 国产免费av片在线无码免费看| 亚洲av日韩精品久久久久久a| 女人18毛片水真多免费看| 2020天堂在线亚洲精品专区| 成人毛片免费观看| 亚洲av最新在线观看网址| 日本人护士免费xxxx视频| 免费播放美女一级毛片| 亚洲精品国自产拍在线观看| 无码日韩人妻AV一区免费l| 免费国产人做人视频在线观看| 日韩在线观看免费| 亚洲午夜久久久久久噜噜噜| 九九热久久免费视频| 国产精品亚洲片在线观看不卡| 免费黄网站在线观看| 亚洲日本在线免费观看| 四虎免费影院ww4164h| 亚洲狠狠成人综合网| 国产精品成人无码免费| 久久久久久亚洲av无码蜜芽| 亚洲精品国产精品国自产观看 | 69视频在线是免费观看| 亚洲免费视频观看| 在线免费观看一级片| 噜噜噜亚洲色成人网站| 久久久久无码专区亚洲av| 久久国产免费一区二区三区| 亚洲区视频在线观看| 免费观看午夜在线欧差毛片| 精品多毛少妇人妻AV免费久久| 亚洲五月六月丁香激情| 黄a大片av永久免费| 人成电影网在线观看免费| 亚洲永久永久永久永久永久精品|