一、安装docker和docker-compose
1、卸载旧版本docker
sudo yum remove -y docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine
2、安装yum-utils
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
3、安装docker
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4、启动docker,设置开机自启
sudo systemctl start docker
sudo systemctl enable docker
5、安装docker-compose
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
添加执行权限
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
查看是否正确安装
docker compose version
Docker Compose version v2.17.2 #有这行回显 显示版本,说明可以使用
二、使用docker-compose布署chatgpt-web
chatgpt-web项目链接:chatgpt-web
1、下载项目
git clone https://github.com/Chanzhaoyu/chatgpt-web
2、编辑 docker-compose配置文件,添加openai密钥
[root@iZ56kkvaq4nlfhZ media] ls
chatgpt-web
[root@iZ56kkvaq4nlfhZ media] cd chatgpt-web/docker-compose/
[root@iZ56kkvaq4nlfhZ docker-compose] ls
docker-compose.yml nginx readme.md
[root@iZ56kkvaq4nlfhZ docker-compose] cat docker-compose.yml
version: '3'services:app:container_name: chatgpt-webimage: chenzhaoyu94/chatgpt-web # 总是使用latest,更新时重新pull该tag镜像即可ports:- 3002:3002environment:# 二选一OPENAI_API_KEY:# 二选一OPENAI_ACCESS_TOKEN:# API接口地址,可选,设置 OPENAI_API_KEY 时可用OPENAI_API_BASE_URL:# API模型,可选,设置 OPENAI_API_KEY 时可用OPENAI_API_MODEL:# 反向代理,可选API_REVERSE_PROXY:# 访问权限密钥,可选AUTH_SECRET_KEY:# 每小时最大请求次数,可选,默认无限MAX_REQUEST_PER_HOUR: 0# 超时,单位毫秒,可选TIMEOUT_MS: 60000# Socks代理,可选,和 SOCKS_PROXY_PORT 一起时生效SOCKS_PROXY_HOST:# Socks代理端口,可选,和 SOCKS_PROXY_HOST 一起时生效SOCKS_PROXY_PORT:# Socks代理用户名,可选,和 SOCKS_PROXY_HOST & SOCKS_PROXY_PORT 一起时生效SOCKS_PROXY_USERNAME:# Socks代理密码,可选,和 SOCKS_PROXY_HOST & SOCKS_PROXY_PORT 一起时生效SOCKS_PROXY_PASSWORD:# HTTPS_PROXY 代理,可选HTTPS_PROXY:nginx:container_name: nginximage: nginx:alpineports:- '80:80'expose:- '80'volumes:- ./nginx/html:/usr/share/nginx/html- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conflinks:- app
[root@iZ56kkvaq4nlfhZ docker-compose]#
3、运行容器
docker-compose up -d
4、docker ps
查看容器运行状态
[root@iZ56kkvaq4nlfhZ docker-compose]# docker ps
CONTAINER ID IMAGE COMMAND CREATED
a396fd8cd03f chenzhaoyu94/chatgpt-web "docker-entrypoint.s…" 18 hours ago Up 18 hours 0.0.0.0:3002->3002/tcp chatgpt-web
5、浏览器访问:IP地址:3002
,布署成功。