Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
SinKy-Yan committed Jun 5, 2022
1 parent db0b0d6 commit f453373
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 172 deletions.
117 changes: 44 additions & 73 deletions Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,92 +1,63 @@
FROM ubuntu:focal
FROM bitnami/git as Git-Clone
WORKDIR /usr/local/code
RUN git clone https://github.com/HibiKier/zhenxun_bot_webui.git && git clone https://github.com/HibiKier/zhenxun_bot.git

###############################################################################

FROM python:3.9-slim-bullseye as Python-Whl-Builder
RUN apt update && apt install -y --no-install-recommends gcc libc6-dev && \
pip install -r https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot-deploy/master/requirements.txt && \
pip install rich requests jinja2 thefuzz aiocache baike imageio

##############################################################################

FROM python:3.9-slim-bullseye as Python-ENV
WORKDIR /home
#拷贝git下载的东西
COPY --from=Git-Clone /usr/local/code /home
#拷贝安装好的python依赖
COPY --from=Python-Whl-Builder /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
COPY --from=Python-Whl-Builder /usr/local/bin/playwright /usr/local/bin/playwright
#拷贝预先准备好的文件
COPY files ./
#环境变量
ENV bot_qq=${bot_qq}
ENV bot_qq_key=${bot_qq_key}
ENV admin_qq=${admin_qq}
ENV webui_passwd={$webui_passwd}
ENV webui_user={$webui_user}
ENV api_key={$api_key}

# 设为非交互命令
ARG DEBIAN_FRONTEND="noninteractive"

# 更换软件源
# RUN sed -i 's/us.archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
# sed -i 's/cn.archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
# sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
# sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list

# apt安装依赖
RUN apt update && apt upgrade -y && apt install -y --no-install-recommends \
python3.9 \
python3-distutils \
python3.9-dev \
vim \
git \
curl \
wget \
ffmpeg \
language-pack-zh-hans \
# apt安装依赖,切换目录是为了后面WebUI可以直接连着减少镜像层数
WORKDIR /home/zhenxun_bot_webui
RUN apt update && \
apt upgrade -y && \
apt install -y --no-install-recommends \
#WebUI要用的node.js
nodejs \
npm \
#PostgreSQL数据库
postgresql \
postgresql-contrib \
#BOT运行需要的依赖
ffmpeg \
libgl1 \
libglib2.0-0 \
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libxkbcommon0 \
libxcomposite1 \
libxrandr2 \
libgbm1 \
libgtk-3-0 \
libasound2 \
gcc \
libsasl2-dev \
libldap2-dev \
ca-certificates \
libssl-dev \
fonts-wqy-microhei

# 调整软链接
RUN rm -f /usr/bin/python3 && \
rm -f /usr/bin/python && \
ln -s /usr/bin/python3.9 /usr/bin/python && \
ln -s /usr/bin/python3.9 /usr/bin/python3

# 调整时区+设定语言
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ENV LANG=zh_CN.UTF-8

# 安装pip,然后安装依赖,并清除缓存
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py && rm -f get-pip.py && \
pip install -r https://raw.githubusercontent.com/zhenxun-org/zhenxun_bot-deploy/master/requirements.txt && \
pip install rich requests jinja2 thefuzz aiocache baike nonebot_plugin_htmlrender imageio && \
rm -rf ~/.cache/pip/*

# 安装chromium
RUN playwright install chromium

# 克隆zhenxun_bot
RUN git clone https://github.com/HibiKier/zhenxun_bot.git

#中文字体,解决原神黄历方块字问题
fonts-wqy-microhei && \
#清缓存
apt clean && \
# 调时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo 'Asia/Shanghai' > /etc/timezone && \
# 安装web_ui
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
apt install -y nodejs && \
npm install -g yarn && \
npm install -g @vue/cli && \
git clone https://github.com/HibiKier/zhenxun_bot_webui.git && \
npm cache clean --force
RUN apt clean && rm -rf /var/lib/apt/lists/*
WORKDIR /home/zhenxun_bot_webui
RUN npm install && npm cache clean --force
npm install -g @vue/cli yarn && \
yarn && \
yarn cache clean

# 拷贝文件
WORKDIR /home
COPY ./go-cqhttp ./go-cqhttp
COPY ./files/docker-entrypoint.sh ./
COPY ./files/config.sh ./
COPY ./files/config.yaml ./zhenxun_bot/configs/
COPY ./files/config.py ./zhenxun_bot/configs/

ENTRYPOINT ["./docker-entrypoint.sh"]
ENTRYPOINT ["./docker-entrypoint.sh"]
Empty file modified LICENSE
100644 → 100755
Empty file.
137 changes: 78 additions & 59 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
<!--
* @Author: 源源圆球 1340793687@outlook.com
* @Date: 2022-06-03 18:01:14
* @LastEditors: 源源圆球 1340793687@outlook.com
* @LastEditTime: 2022-06-05 16:04:31
* @FilePath: /docker/README.md
* @Description:
*
* Copyright (c) 2022 by 源源圆球 1340793687@outlook.com, All Rights Reserved.
-->
# [绪山真寻BOT](https://github.com/HibiKier/zhenxun_bot)的Docker版镜像🐋

![](https://img.shields.io/github/workflow/status/SinKy-Yan/zhenxunbot-docker/Build%20Docker%20image?label=%E9%95%9C%E5%83%8F%E7%BC%96%E8%AF%91&style=for-the-badge)
![](https://img.shields.io/docker/image-size/jyishit/zhenxun_bot?label=%E9%95%9C%E5%83%8F%E5%A4%A7%E5%B0%8F&style=for-the-badge)
![](https://img.shields.io/docker/pulls/jyishit/zhenxun_bot?label=%E4%B8%8B%E8%BD%BD%E6%AC%A1%E6%95%B0&style=for-the-badge)
![](https://img.shields.io/badge/Python%E7%89%88%E6%9C%AC-3.9-ff69b4?style=for-the-badge)
![](https://img.shields.io/badge/%E6%94%AF%E6%8C%81%E5%B9%B3%E5%8F%B0-arm64%7Camd64-8B008B?style=for-the-badge)
![](https://img.shields.io/badge/%E6%94%AF%E6%8C%81%E6%9E%B6%E6%9E%84-amd64%7Carm64-8B008B?style=for-the-badge)


![GitHub release (latest by date)](https://img.shields.io/github/v/release/HibiKier/zhenxun_bot?label=%E7%9C%9F%E5%AF%BBBOT%E7%89%88%E6%9C%AC&style=for-the-badge)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/Mrs4s/go-cqhttp?label=gocq%E7%89%88%E6%9C%AC&style=for-the-badge)
Expand All @@ -13,24 +24,19 @@

**镜像内已集成运行BOT需要的PostgreSQL🐘、绪山真寻BOT本体、以及真寻BOT-WebUI😋**

额外还有Python3.9、PIP、PIP编译工具链、Vim、wget、Git、中文语言包

![Git](https://img.shields.io/badge/-Git-F05032?style=flat-square&logo=git&logoColor=white)
![Vim](https://img.shields.io/badge/-Vim-019733?style=flat-square&&logo=Vim&logoColor=white)
![Ubuntu](https://img.shields.io/badge/-Ubuntu-E95420?style=flat-square&&logo=ubuntu&logoColor=white)
![Ubuntu](https://img.shields.io/badge/-Python-3776AB?style=flat-square&&logo=python&logoColor=white)

<img align=right src='https://github.githubassets.com/images/mona-whisper.gif' /> 顺手点个Star⭐呗~
<img align=right src='https://github.githubassets.com/images/mona-whisper.gif' />

顺手点个Star⭐呗~

## 注意事项⚠

镜像有点大,解压后接近3GB,需要有足够的空间(可能会出个精简版镜像)
## 需要知道💡

需要有1G以上的内存
你的机器最好有1G以上的空闲内存

**先确定能用go-cqhttp登录上BOT的QQ,否则需要进入容器查看日志**

除了集成运行BOT必须的Python依赖之外,还有`rich``requests``jinja2``thefuzz``aiocache``baike``imageio`,这些是添加额外插件所需的常见依赖

## 迁移数据库📑

迁移数据库是为了如果你以前部署过真寻的话,可以继承好感度、金币等数据
Expand All @@ -39,15 +45,23 @@

然后将`zhenxun.sql`拷贝到将要部署Docker版真寻的宿主机的`~/my_plugins`目录下,**如果该目录不存在则需要手动创建**

然后就可以了,容器创建时会检测有没有这个文件,有的话就会帮你导入的,不过只是帮你导入,数据库本身有问题的话就跟我没关系了
然后就可以了,容器创建时会检测有没有这个文件,有的话就会帮你导入的,不过只是帮你导入,数据库本身有问题导致报错就跟我没关系了

## 已知问题😥

无法使用`检查更新真寻`自动更新真寻,会报错`Invalid cross-device link: '/home/zhenxun_bot/plugins' -> '/home/zhenxun_bot/backup/plugins'`,我怀疑可能是docker使用的overlay文件系统的问题,希望有谁能帮我解决一下

跟真寻说`重启`之后重启成功也不会说已经重启完成,需要重启容器才会说,但是其实已经重启过了,**不影响使用**

第一次运行容器会自动停止一次容器,不过它应该会自动重启,**不影响使用**

## 快速开始🎉

将下面命令中**单引号内**`bot的QQ号``bot的QQ密码``管理员QQ号``识图API-KEY``WebUI用户名``WebUI密码`替换成对应的账号和密码之后执行就好了

⚠识图API-KEY不替换也行,但是运行之后bot的识图功能会用不了,以后你想再加上的话需要进入容器自己更改,API_KEY通过[该网址](https://saucenao.com/user.php?page=search-api)注册获取

⚠会在当前用户的用户根目录里新建一个叫`my_plugins`的文件夹,这就是自定义插件的目录,可以使用`cd ~/my_plugins`命令来进入,进入后就可以下载需要的插件了
⚠会在当前用户的用户根目录里新建一个叫`my_plugins`的文件夹,这就是自定义插件的目录,同时里面也会有`WebUI``gocq`的日志文件,可以使用`cd ~/my_plugins`命令来进入

```
docker run -itd --restart=on-failure:3 \
Expand All @@ -63,11 +77,11 @@ docker run -itd --restart=on-failure:3 \
jyishit/zhenxun_bot
```

执行之后会开始从Docker Hub上下载镜像,下载并解压之后容器创建成功的话终端会返回一长串的容器ID,下载速度取决于你的网速,推荐设置一个镜像加速器
执行之后会开始从Docker Hub上下载镜像,下载并解压之后容器创建成功的话终端会返回一长串的容器ID,下载速度取决于你的网速,推荐设置一个[镜像加速器](https://www.runoob.com/docker/docker-mirror-acceleration.html)

第一次运行容器会自动停止一次容器,不过它应该会自动重启
查看Docker日志,成功运行之后可以去`容器IP:8081`进入真寻的WebUI

查看Docker日志,成功运行之后可以去`容器IP:8081`进入真寻的WebUI,如果你没有自定义账号密码的话,默认账号是`admin`,密码是`123456`
<div align="center"><img src="./image/Start.png" width="80%"/></div>

## 需要帮助🐱‍💻?

Expand All @@ -76,49 +90,54 @@ jyishit/zhenxun_bot
[![加入QQ群](https://img.shields.io/badge/QQ%E7%BE%A4-1034439737-ddff95?style=for-the-badge)](https://jq.qq.com/?_wv=1027&k=u8PgBkMZ)

## 容器内文件结构📂

```
/home
├── docker-entrypoint.sh
├── go-cqhttp
│   ├── config.yml
│   ├── data
│   ├── device.json
│   ├── go-cqhttp
│   ├── gocq.log
│   ├── logs
│   └── session.token
│ ├── data
│ ├── logs
│ ├── config.yml
│ ├── device.json
│ ├── go-cqhttp
│ └── session.token
├── zhenxun_bot
│   ├── basic_plugins
│   ├── bot.py
│   ├── configs
│   ├── data
│   ├── docs_image
│   ├── LICENSE
│   ├── log
│   ├── logo.png
│   ├── models
│   ├── my_plugins
│   ├── plugins
│   ├── poetry.lock
│   ├── pyproject.toml
│   ├── README.md
│   ├── resources
│   ├── restart.sh
│   ├── services
│   ├── update_info.json
│   ├── utils
│   └── __version__
└── zhenxun_bot_webui
├── babel.config.js
├── jsconfig.json
├── LICENSE
├── node_modules
├── package.json
├── package-lock.json
├── public
├── README.md
├── src
├── vue.config.js
├── webui.log
└── yarn.lock
│ ├── .git
│ ├── .github
│ ├── basic_plugins
│ ├── configs
│ ├── data
│ ├── docs_image
│ ├── extensive_plugin
│ ├── log
│ ├── models
│ ├── my_plugins
│ ├── plugins
│ ├── resources
│ ├── services
│ ├── utils
│ ├── .env
│ ├── .env.dev
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── __version__
│ ├── bot.py
│ ├── logo.png
│ ├── poetry.lock
│ ├── pyproject.toml
│ ├── restart.sh
│ └── update_info.json
├── zhenxun_bot_webui
│ ├── .git
│ ├── dist
│ ├── node_modules
│ ├── public
│ ├── src
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── babel.config.js
│ ├── jsconfig.json
│ ├── package.json
│ ├── vue.config.js
│ └── yarn.lock
└── docker-entrypoint.sh
Loading

0 comments on commit f453373

Please sign in to comment.