Skip to content

Commit 21cf1bd

Browse files
authored
新增docker-compose部署 (Chanzhaoyu#187)
* feat docker-compose deploy * feat docker-compose deploy
1 parent f234aeb commit 21cf1bd

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

docker-compose/docker-compose.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
image: chenzhaoyu94/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可
6+
ports:
7+
- 3002:3002
8+
environment:
9+
# 二选一
10+
OPENAI_API_KEY: xxxx
11+
# 二选一
12+
OPENAI_ACCESS_TOKEN: xxxxxx
13+
# 反向代理,可选
14+
API_REVERSE_PROXY: xxx
15+
# 超时,单位毫秒,可选
16+
TIMEOUT_MS: 60000
17+
nginx:
18+
build: nginx
19+
image: chatgpt/nginx
20+
ports:
21+
- "80:80"
22+
expose:
23+
- "80"
24+
volumes:
25+
- ./nginx/html/:/etc/nginx/html/
26+
links:
27+
- app

docker-compose/nginx/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM hub.c.163.com/library/nginx
2+
3+
MAINTAINER jo "[email protected]"
4+
5+
RUN rm -rf /etc/nginx/conf.d/default.conf
6+
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
7+
COPY ./html/ /usr/share/nginx/html/
8+
EXPOSE 80
9+
10+
CMD ["nginx", "-g", "daemon off;"]

docker-compose/nginx/nginx.conf

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
charset utf-8;
5+
error_page 500 502 503 504 /50x.html;
6+
location = / {
7+
root /usr/share/nginx/html;
8+
index index.html index.htm;
9+
}
10+
11+
location /api {
12+
proxy_set_header X-Real-IP $remote_addr; #转发用户IP
13+
proxy_pass http://app:3002;
14+
}
15+
16+
proxy_set_header Host $host;
17+
proxy_set_header X-Real-IP $remote_addr;
18+
proxy_set_header REMOTE-HOST $remote_addr;
19+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20+
}

docker-compose/readme.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### docker-compose 部署教程
2+
- 将打包好的前端文件放到 `nginx/html` 目录下
3+
- ```shell
4+
# 打包启动
5+
docker-compose build
6+
docker-compose up -d
7+
```
8+
- ```shell
9+
# 查看运行状态
10+
docker ps
11+
```
12+
- ```shell
13+
# 结束运行
14+
docker-compose down
15+
```

0 commit comments

Comments
 (0)