开发个人Ollama-Chat–7 服务部署
服务部署
go-ChatGPT
项目涉及的中间件服务较多,以下部署文件目录:
|-- chat-api
| |-- etc
| | `-- config.yaml
| `-- logs
|-- chat-rpc
| |-- etc
| | `-- config.yaml
| `-- logs
|-- docker-compose.yaml
|-- mysql
| `-- data
|-- nginx
| |-- conf
| | `-- conf.d
| `-- data
| `-- front
|-- ollama
| |-- history
| |-- id_ed25519
| `-- id_ed25519.pub
|-- redis
| `-- data
| `-- dump.rdb
|-- user-api
| |-- etc
| | `-- config.yaml
| `-- logs
`-- user-rpc|-- etc| `-- config.yaml`-- logs
docker-compose.yaml
version: '3.8'services:user-rpc:image: eilinge/open-ui-user-rpccontainer_name: user-rpcports:- "9001:9001"volumes:- ./user-rpc/etc/config.yaml:/app/etc/config.yaml- ./user-rpc/logs:/app/logsnetworks:- defaultdepends_on:- mysql- redis- etcduser-api:image: eilinge/open-ui-user-apicontainer_name: user-apiports:- "8081:8081"volumes:- ./user-api/etc/config.yaml:/app/etc/config.yaml- ./user-api/logs:/app/logsnetworks:- defaultdepends_on:- mysql- redis- etcdchat-rpc:image: eilinge/open-ui-chat-rpccontainer_name: chat-rpcports:- "9002:9002"volumes:- ./chat-rpc/etc/config.yaml:/app/etc/config.yaml- ./chat-rpc/logs:/app/logsnetworks:- defaultdepends_on:- mysql- redis- etcdchat-api:image: eilinge/open-ui-chat-apicontainer_name: chat-apiports:- "8082:8082"volumes:- ./chat-api/etc/config.yaml:/app/etc/config.yaml- ./chat-api/logs:/app/logsnetworks:- defaultdepends_on:- mysql- redis- etcdredis: # 服务名称image: redis:7.2.4 # redis镜像版本container_name: openui-redis # 容器名称volumes:- ./redis/data:/data # 映射数据目录,宿主机:容器restart: always # 容器开机自启ports:- 6379:6379privileged: true # 获取宿主机root权限networks:- defaultmysql: # 服务名称image: mysql:8.2.0 # redis镜像版本container_name: openui-mysql # 容器名称environment:- MYSQL_ROOT_PASSWORD=123456volumes:- ./mysql/data:/data # 映射数据目录,宿主机:容器restart: always # 容器开机自启ports:- 3306:3306privileged: true # 获取宿主机root权限networks:- defaultetcd:image: "bitnami/etcd:latest" # 使用bitnami的etcd镜像container_name: openui-etcdenvironment:- ALLOW_NONE_AUTHENTICATION=yes # 允许无认证访问- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379 # 客户端访问地址- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379ports:- 2379:2379- 2380:2380networks:- defaultetcdkeeper:container_name: openui-etcdkeeperimage: evildecay/etcdkeeper:v0.7.6ports:- "8099:8080"networks:- defaultnginx:image: nginx:latestcontainer_name: openui-nginxports:- "8080:80"- "8443:443"volumes:- ./nginx/conf/conf.d:/etc/nginx/conf.d- ./nginx/logs:/var/log/nginx- ./nginx/data/front:/data/front- /etc/nginx/ssl:/etc/nginx/ssl networks:- defaultollama:volumes:- ./ollama:/root/.ollamacontainer_name: ollamatty: truerestart: unless-stoppedimage: ollama/ollamaenvironment:- name=valueports:- 11434:11434networks:- defaultdeploy:resources:reservations:devices:- driver: nvidiacount: 1capabilities: [gpu]networks:default:external: truename: openui-net
Nginx 配置
经过前面几章的学习,相信一步一步走过来的同学会发现,user-api
和chat-api
是2个独立的服务,各自启动在不同端口上,router
也不一致,open-webUI
如何实现调用一个统一
的服务入口,就可以分别调用多个不同服务呢?
server {listen 80;listen 443 ssl; server_name _;ssl_certificate /etc/nginx/ssl/server.pem;ssl_certificate_key /etc/nginx/ssl/server.key;location /static/ {root /data/front;}location / {proxy_pass http://chat-api:8082;proxy_set_header X-Forwarded-Proto $scheme; }location /api/v1/auths {proxy_pass http://user-api:8081;proxy_set_header X-Forwarded-Proto $scheme;}
}
答案就在 nginx
的配置文件defalut.conf
中,user
服务的router
会走/api/v1/auths
,chat
相关服务则会走/
项目目录
jackwillsmith/go-chatgpt-env: go chatgpt env deploy (github.com)
jackwillsmith/openui-backend-go: openui-backend-go (github.com)
jackwillsmith/openui-svelte-build (github.com)