开发个人Go-ChatGPT--5 模型管理 (三)
服务部署
go-ChatGPT
项目涉及的中间件服务较多,以下部署文件目录:
bash
|-- 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
yaml
version: '3.8'
services:
user-rpc:
image: eilinge/open-ui-user-rpc
container_name: user-rpc
ports:
- "9001:9001"
volumes:
- ./user-rpc/etc/config.yaml:/app/etc/config.yaml
- ./user-rpc/logs:/app/logs
networks:
- default
depends_on:
- mysql
- redis
- etcd
user-api:
image: eilinge/open-ui-user-api
container_name: user-api
ports:
- "8081:8081"
volumes:
- ./user-api/etc/config.yaml:/app/etc/config.yaml
- ./user-api/logs:/app/logs
networks:
- default
depends_on:
- mysql
- redis
- etcd
chat-rpc:
image: eilinge/open-ui-chat-rpc
container_name: chat-rpc
ports:
- "9002:9002"
volumes:
- ./chat-rpc/etc/config.yaml:/app/etc/config.yaml
- ./chat-rpc/logs:/app/logs
networks:
- default
depends_on:
- mysql
- redis
- etcd
chat-api:
image: eilinge/open-ui-chat-api
container_name: chat-api
ports:
- "8082:8082"
volumes:
- ./chat-api/etc/config.yaml:/app/etc/config.yaml
- ./chat-api/logs:/app/logs
networks:
- default
depends_on:
- mysql
- redis
- etcd
redis: # 服务名称
image: redis:7.2.4 # redis镜像版本
container_name: openui-redis # 容器名称
volumes:
- ./redis/data:/data # 映射数据目录,宿主机:容器
restart: always # 容器开机自启
ports:
- 6379:6379
privileged: true # 获取宿主机root权限
networks:
- default
mysql: # 服务名称
image: mysql:8.2.0 # redis镜像版本
container_name: openui-mysql # 容器名称
environment:
- MYSQL_ROOT_PASSWORD=123456
volumes:
- ./mysql/data:/data # 映射数据目录,宿主机:容器
restart: always # 容器开机自启
ports:
- 3306:3306
privileged: true # 获取宿主机root权限
networks:
- default
etcd:
image: "bitnami/etcd:latest" # 使用bitnami的etcd镜像
container_name: openui-etcd
environment:
- ALLOW_NONE_AUTHENTICATION=yes # 允许无认证访问
- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379 # 客户端访问地址
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ports:
- 2379:2379
- 2380:2380
networks:
- default
etcdkeeper:
container_name: openui-etcdkeeper
image: evildecay/etcdkeeper:v0.7.6
ports:
- "8099:8080"
networks:
- default
nginx:
image: nginx:latest
container_name: openui-nginx
ports:
- "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:
- default
ollama:
volumes:
- ./ollama:/root/.ollama
container_name: ollama
tty: true
restart: unless-stopped
image: ollama/ollama
environment:
- name=value
ports:
- 11434:11434
networks:
- default
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
networks:
default:
external: true
name: openui-net
Nginx 配置
经过前面几章的学习,相信一步一步走过来的同学会发现,user-api
和chat-api
是2个独立的服务,各自启动在不同端口上,router
也不一致,open-webUI
如何实现调用一个统一
的服务入口,就可以分别调用多个不同服务呢?
json
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)