一、环境准备
服务器一台 (最好美区)
我的环境: liunx (centos 7)
二、搭建步骤
1、安装 docker
1 2 3 4 5 6 7 8
| sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine
|
安装所需的软件包。yum-utils 提供了 yum-config-manager ,并且 device mapper 存储驱动程序需要 device-mapper-persistent-data 和 lvm2。
1 2 3
| sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
|
使用官方源地址(国外服务器选用)
1 2 3
| sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
|
阿里云
1 2 3
| sudo yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
|
清华大学源
1 2 3
| sudo yum-config-manager \ --add-repo \ https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
|
1
| sudo yum install -y docker-ce docker-ce-cli containerd.io
|
1 2 3
| systemctl start docker
systemctl enable docker --now
|
这步可以省略,一般搭建 chatgpt-web 需要的是国外服务器
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2" } EOF sudo systemctl daemon-reload sudo systemctl restart docker
|
2、安装 Docker-compose
1 2 3 4 5 6 7 8 9 10 11 12 13
| sudo curl -L "https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.1.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
docker-compose --version
|
3、安装 ChatGPT-web
创建目录
1 2
| mkdir -p /opt/chatgpt_web cd /opt/chatgpt_web
|
创建 docker-compose.yml 文件
在文件中填入以下内容,然后 :wq 保存
1 2 3 4 5 6 7 8 9 10 11 12 13
| version: "3" services: app: image: chenzhaoyu94/chatgpt-web:latest ports: - 3002:3002 environment: OPENAI_API_KEY: 自己申请的key(sk-xxx) TIMEOUT_MS: 60000 OPENAI_API_MODEL: gpt-3.5-turbo AUTH_SECRET_KEY: 访问密码
|
创建完成后,运行
然后就可以通过 IP:3002 来访问 ChatGPT