Skip to content

Commit c8a02bc

Browse files
author
gwind
committed
update product deploy example for openai
1 parent b145b44 commit c8a02bc

File tree

4 files changed

+111
-1
lines changed

4 files changed

+111
-1
lines changed

deploy/openai/production/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 部署生产环境
2+
3+
进入 `deploy/openai/production` 目录
4+
5+
1. 查看 docker-compose.yml 文件,修改配置
6+
2. 查看 ga.yml 文件,修改配置
7+
3. 启动服务
8+
9+
```bash
10+
docker compose up -d
11+
```
12+
13+
## FAQ
14+
15+
### 配置 key
16+
17+
```bash
18+
export OPENAI_API_KEY=cs-yyy
19+
# 设置 key
20+
docker compose exec etcd etcdctl put $OPENAI_API_KEY '{"token":"sk-xxx", "count":0}'
21+
# 获取 key 配置
22+
docker compose exec etcd etcdctl get $OPENAI_API_KEY
23+
```
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
version: '3.1'
2+
3+
services:
4+
5+
traefik:
6+
image: traefik:v2.10
7+
container_name: traefik
8+
ports:
9+
- "443:443"
10+
volumes:
11+
- /var/run/docker.sock:/var/run/docker.sock
12+
- ./letsencrypt:/letsencrypt
13+
command:
14+
# - --log.level=DEBUG
15+
- --providers.docker
16+
- --providers.docker.exposedByDefault=false
17+
- --entrypoints.websecure.address=:443
18+
- --certificatesresolvers.myresolver.acme.tlschallenge
19+
- --certificatesresolvers.myresolver.acme.email=YOUR_EMAIL
20+
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
21+
22+
openai:
23+
image: ooclab/ga:v0.9.15
24+
labels:
25+
- traefik.enable=true
26+
- traefik.http.routers.ga-service.rule=Host(`YOUR_DOMAIN_NAME`)
27+
- traefik.http.routers.ga-service.entrypoints=websecure
28+
- traefik.http.routers.ga-service.tls.certresolver=myresolver
29+
- traefik.http.services.ga-service.loadbalancer.server.port=2999
30+
volumes:
31+
- "$PWD/ga.yml:/etc/ga/config.yml"
32+
# environment:
33+
# - GA_DEBUG=true
34+
expose:
35+
- "2999"
36+
# ports:
37+
# - "2999:2999"
38+
# restart: unless-stopped
39+
depends_on:
40+
- etcd
41+
42+
etcd:
43+
image: quay.io/coreos/etcd:v3.5.11
44+
# image: quay.mirrors.ustc.edu.cn/coreos/etcd:v3.5.11
45+
container_name: etcd
46+
environment:
47+
- ETCD_NAME=etcd
48+
- ETCD_DATA_DIR=/etcd-data
49+
- ETCD_ADVERTISE_CLIENT_URLS=http://your-host-ip:2379
50+
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
51+
- ETCD_INITIAL_ADVERTISE_PEER_URLS=http://your-host-ip:2380
52+
- ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380
53+
- ETCD_INITIAL_CLUSTER=etcd=http://your-host-ip:2380
54+
- ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster-1
55+
- ETCD_INITIAL_CLUSTER_STATE=new
56+
expose:
57+
- "2379"
58+
- "2380"
59+
#ports:
60+
# - "127.0.0.1:2379:2379"
61+
# - "127.0.0.1:2380:2380"
62+
volumes:
63+
- ./etcd-data:/etcd-data

deploy/openai/production/ga.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "2"
2+
3+
# start the forward server
4+
listen: ":2999"
5+
6+
services:
7+
8+
httpbin:
9+
path_prefix: /httpbin
10+
backend: https://httpbin.org
11+
middlewares:
12+
- name: logger
13+
- name: debug
14+
15+
openai:
16+
path_prefix: /v1
17+
backend: https://api.openai.com/v1
18+
middlewares:
19+
- name: logger
20+
- name: debug
21+
- name: openai
22+
etcd_addr: http://etcd:2379
23+
# limit_day: 100

middlewares/openai/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ btw, ga 是透明网关,因此 openai api 自身的限制配额和用户账户
1212

1313
## 使用
1414

15-
[配置 openai middle 示例](../../deploy/openai/README.md)
15+
- [配置 openai middle 示例](../../deploy/openai/README.md)
16+
- [生厂环境部署示例](../../deploy/openai/production/README.md)
1617

1718
## TODO
1819

0 commit comments

Comments
 (0)