Skip to content

Commit

Permalink
doc: update
Browse files Browse the repository at this point in the history
Signed-off-by: 117503445 <[email protected]>
  • Loading branch information
117503445 committed Nov 21, 2023
1 parent 56ee77a commit 74647e1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 75 deletions.
112 changes: 54 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ version: '3'

services:
yunzai-web:
# docker pull registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web && docker image tag registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web 117503445/yunzai-web
image: 117503445/yunzai-web
image: registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web
container_name: yunzai-web
restart: unless-stopped
ports:
- 8080:8080
depends_on:
redis:
condition: service_healthy
volumes:
- ./data/yunzai-web/data:/root/Yunzai-Bot/data
- ./data/yunzai-web/web-data/images:/root/Yunzai-Bot/web-data/images
- ./data/yunzai-web/yunzai-bot-data:/workspace/Yunzai-Bot/data # data of `Yunzai-Bot`
- ./data/yunzai-web/be-images:/workspace/Yunzai-Bot/web-data/images # images of backend

- ./config/plugins:/workspace/Yunzai-Bot/user_plugins # plugins of `Yunzai-Bot`
# - ./config/config.json:/workspace/Yunzai-Bot/config.json # config of backend, unconment this line when config.json is provided

- ./dev-data/vsc:/root/.vscode-server # vscode-server cache
redis:
# docker pull registry.cn-hangzhou.aliyuncs.com/117503445-mirror/redis:alpine && docker image tag registry.cn-hangzhou.aliyuncs.com/117503445-mirror/redis:alpine redis:alpine
image: redis:alpine
image: registry.cn-hangzhou.aliyuncs.com/117503445-mirror/redis:alpine
restart: unless-stopped
volumes:
- ./data/redis/data:/data
Expand All @@ -44,13 +48,6 @@ services:
timeout: 1s
```
[可选] 使用阿里云容器服务拉取镜像,速度更快
```sh
docker pull registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web && docker image tag registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web 117503445/yunzai-web
docker pull registry.cn-hangzhou.aliyuncs.com/117503445-mirror/redis:alpine && docker image tag registry.cn-hangzhou.aliyuncs.com/117503445-mirror/redis:alpine redis:alpine
```

在此文件夹下运行命令
```sh
Expand All @@ -63,6 +60,40 @@ Enjoy :)

## 使用技巧

### 插件管理

[miao-plugin](https://gitee.com/yoimiya-kokomi/miao-plugin) 插件为例

#### 插件安装

先将插件下载至 `./config/plugins/` 目录

```sh
git clone --depth=1 https://gitee.com/yoimiya-kokomi/miao-plugin.git ./config/plugins/miao-plugin
```

重启容器,应用插件更新

```sh
docker compose up -d
```

#### 插件升级

拉取更改

```sh
cd ./config/plugins/miao-plugin
git pull
```

重启容器,应用插件更新

```sh
docker compose up -d
```


### 帮助

输入 `#帮助` 查看 Yunzai 的帮助
Expand Down Expand Up @@ -105,77 +136,42 @@ ck 指的是 [米游社](https://www.miyoushe.com/ys) 的 cookie。Yunzai 在进

```json
{
"multiUser": true,
"multiUser": false,
"users": {
"user1": {
"password": "pass1",
"qq": 805475874
"qq": "10000000"
},
"user2": {
"password": "pass2",
"qq": 805475875
"qq": "10000001"
}
}
}
```

定义了 2 个用户,分别是

- 用户名 user1 密码 pass1 QQ号 805475874
- 用户名 user2 密码 pass2 QQ号 805475875
- 用户名 user1 密码 pass1 QQ号 10000000
- 用户名 user2 密码 pass2 QQ号 10000001

QQ号字段不要求和真实 QQ 号一致,只要不同用户的 QQ 字段互相不同即可。其中 `805475874` 是个 magic number, 表示 `user1` 是管理员。
QQ号字段不要求和真实 QQ 号一致,只要不同用户的 QQ 字段互相不同即可。其中 `10000000` magic number, 表示 `user1` 是管理员。因为 `10000001` 不是 `10000000`, 所以 `user2` 是普通用户

然后挂载配置文件即可

```yaml
volumes:
- ./config/config.json:/root/Yunzai-Bot/web-data/config.json
```
目前采用了 Basic Auth 方案,建议配置 HTTPS 保障安全性。
### 安装插件
此项目已自带 miao-plugin,但是也可以很方便的安装第三方插件
以 [call_of_seven_saints](https://gitee.com/huangshx2001/call_of_seven_saints) 插件为例
先下载插件 `git clone https://gitee.com/huangshx2001/call_of_seven_saints.git ./data/plugins/call_of_seven_saints/`

然后将宿主机的 `./data/plugins/call_of_seven_saints` 挂载到容器中

```yaml
volumes:
- ./data/plugins/call_of_seven_saints:/root/Yunzai-Bot/plugins/call_of_seven_saints
- ./config/config.json:/workspace/Yunzai-Bot/config.json
```
再执行 `docker compose up -d` 即可

### 更新镜像

当 `Yunzai-Bot` 或 `miao-plugin` 更新时,需要通过本节描述的方法进行更新。

1. 确定远端存在更新的镜像

Yunzai-Bot 自带的更新是不能用的,只能通过拉取新镜像的方式进行更新。
目前采用了 Basic Auth 方案,建议在网关上配置 HTTPS 以保障安全性。
- 默认 tag (latest) 只有在本 repo 开发者验证功能可用后,才会进行更新。
- 每夜 tag (nightly) 每天都会自动构建一次,会包含构建时最新的插件版本。但是不确保功能正常。
### 镜像更新
2. 拉取镜像
`Yunzai-Bot` 或 `yunzai-bot-web` 更新时,需要通过本节描述的方法进行镜像更新。其中 `Yunzai-Bot` 基本已经停更了;`yunzai-bot-web` 修 bug 或者增添新功能(比较少见) 时会更新。

```sh
docker compose pull
# or
docker pull registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web && docker image tag registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web 117503445/yunzai-web
```

3. 以新镜像启动容器

```sh
docker compose up -d
```

Expand Down
13 changes: 11 additions & 2 deletions doc/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ attach 到容器中,修改代码
启动服务
```sh
cd Yunzai-Bot
node ./lib/tools/server.js
```

Expand All @@ -26,6 +25,16 @@ docker build -t 117503445/yunzai-bot .
docker push 117503445/yunzai-bot
docker tag 117503445/yunzai-bot registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web
docker push registry.cn-hangzhou.aliyuncs.com/117503445-mirror/yunzai-web
```

## 本地开发

在项目根目录执行

docker compose -f doc/docker/docker-compose.yml up -d
```sh
docker compose -f doc/docker/docker-compose.yml up --build
```

会在 `doc/docker` 目录下生成 `data` `config` `dev-data` 目录,其中 `dev-data` 用来储存镜像中的 VSCode Server 缓存等数据

可以通过 `http://localhost:8080` 访问项目
11 changes: 0 additions & 11 deletions doc/docker/README.md

This file was deleted.

6 changes: 2 additions & 4 deletions doc/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ services:
- ./data/yunzai-web/be-images:/workspace/Yunzai-Bot/web-data/images # images of backend

# - ./config/config.json:/workspace/Yunzai-Bot/config.json # config of backend
- ./config/plugins:/workspace/Yunzai-Bot/user_plugins

- ./config/plugins:/workspace/Yunzai-Bot/user_plugins # plugins of `Yunzai-Bot`
- ../../src/Yunzai-Bot/docker-entrypoint.py:/workspace/Yunzai-Bot/docker-entrypoint.py

- ./dev-data/vsc:/root/.vscode-server # vscode-server cache


redis:
# docker pull registry.cn-hangzhou.aliyuncs.com/117503445-mirror/redis:alpine && docker image tag registry.cn-hangzhou.aliyuncs.com/117503445-mirror/redis:alpine redis:alpine
image: redis:alpine
Expand Down

0 comments on commit 74647e1

Please sign in to comment.