<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

    主站蜘蛛池模板: 亚洲精品成人无限看| 亚洲私人无码综合久久网| 免费观看无遮挡www的小视频| 亚洲精品无AMM毛片| 久久亚洲AV无码西西人体| 最近免费中文在线视频| 美景之屋4在线未删减免费| 亚洲国产第一页www| 国产无遮挡又黄又爽免费视频| 鲁丝片一区二区三区免费| 亚洲欧美日韩综合久久久| 亚洲成亚洲乱码一二三四区软件| 99久久免费精品国产72精品九九| 狠狠躁狠狠爱免费视频无码| 亚洲乱码中文字幕小综合| 亚洲中文字幕久久精品无码APP| 18禁免费无码无遮挡不卡网站| 一区二区三区在线免费观看视频| 亚洲性色成人av天堂| 国产精品亚洲不卡一区二区三区| 欧美三级在线电影免费| 国产高清不卡免费视频| 99亚洲男女激情在线观看| 亚洲性色成人av天堂| 亚洲AV无码久久精品蜜桃| 免费中文字幕在线| 最近最新的免费中文字幕| 久久免费观看国产精品88av| 牛牛在线精品免费视频观看| 亚洲中文字幕久久无码| 亚洲一区二区中文| 亚洲乱码一区二区三区在线观看 | 亚洲人成777在线播放| 久久久亚洲精品蜜桃臀| 四虎在线播放免费永久视频| 成视频年人黄网站免费视频| 99re免费99re在线视频手机版| 中出五十路免费视频| 免费无码专区毛片高潮喷水| 亚洲精品蜜夜内射| 亚洲小说图区综合在线|