🚀 update deploy step and guide (resolve #8)

This commit is contained in:
yanyongyu 2021-09-11 17:47:58 +08:00
parent 1453825771
commit c7e4624b52
4 changed files with 43 additions and 28 deletions

1
.env
View File

@ -2,6 +2,7 @@ ENVIRONMENT=dev
HOST=0.0.0.0
PORT=8086
DEBUG=false
SUPERUSERS=[]
PLUGINS=[]
PLUGIN_DIRS=["src/plugins"]

View File

@ -6,11 +6,17 @@ ENV LC_ALL zh_CN.UTF-8
ENV TZ Asia/Shanghai
ENV DEBIAN_FRONTEND noninteractive
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak &&\
echo "deb http://mirrors.aliyun.com/debian/ buster main" >> /etc/apt/sources.list\
&& echo "deb http://mirrors.aliyun.com/debian/ buster-updates main" >> /etc/apt/sources.list\
&& echo "deb http://mirrors.aliyun.com/debian-security/ buster/updates main" >> /etc/apt/sources.list\
&& apt-get update && apt-get install -y locales locales-all fonts-noto
ENV MAX_WORKERS 1
ENV APP_MODULE bot:app
# ENV XVFB_INSTALLED true
# RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak &&\
# echo "deb http://mirrors.aliyun.com/debian/ buster main" >> /etc/apt/sources.list\
# && echo "deb http://mirrors.aliyun.com/debian/ buster-updates main" >> /etc/apt/sources.list\
# && echo "deb http://mirrors.aliyun.com/debian-security/ buster/updates main" >> /etc/apt/sources.list\
# && apt-get update && apt-get install -y locales locales-all fonts-noto
RUN apt-get update && apt-get install -y locales locales-all fonts-noto
# RUN python3 -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
@ -23,11 +29,11 @@ RUN poetry export --without-hashes -f requirements.txt \
&& echo "Install playwright headless browser..." \
&& poetry run playwright install chromium \
&& apt-get install -y libnss3-dev libxss1 libasound2 libxrandr2\
libatk1.0-0 libgtk-3-0 libgbm-dev\
libatk1.0-0 libgtk-3-0 libgbm-dev libxshmfense1\
&& poetry install --no-dev
RUN echo "Install wkhtmltox renderer..." \
&& chmod +x ./scripts/download_wkhtmltox.sh \
&& ./scripts/download_wkhtmltox.sh buster_amd64 \
&& apt-get install -y xvfb ./wkhtmltox_*.deb\
&& rm wkhtmltox_*.deb
# RUN echo "Install wkhtmltox renderer..." \
# && chmod +x ./scripts/download_wkhtmltox.sh \
# && ./scripts/download_wkhtmltox.sh buster_amd64 \
# && apt-get install -y xvfb ./wkhtmltox_*.deb\
# && rm wkhtmltox_*.deb

View File

@ -2,7 +2,7 @@
* @Author : yanyongyu
* @Date : 2020-09-10 17:11:45
* @LastEditors : yanyongyu
* @LastEditTime : 2021-06-10 23:34:41
* @LastEditTime : 2021-09-11 17:46:15
* @Description : README
* @GitHub : https://github.com/yanyongyu
-->
@ -28,18 +28,27 @@ GitHub Bot for QQ
## 部署
部署 `QQ-GitHub-Bot` 前,需要先行部署 [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) 并配置连接。
配置连接的方法参考 `nonebot2` 文档: [配置协议端](https://v2.nonebot.dev/guide/cqhttp-guide.html#%E9%85%8D%E7%BD%AE-cqhttp-%E5%8D%8F%E8%AE%AE%E7%AB%AF-%E4%BB%A5-qq-%E4%B8%BA%E4%BE%8B)
1. 使用 `nb-cli`
1. 下载 [`docker-compose.yml`](./docker-compose.yml) 以及 [`.env`](./.env) 配置文件至任意空目录,修改 `.env` 中的如下配置项:
```bash
pip install nb-cli[deploy]
nb build
nb up
```dotenv
HOST=0.0.0.0
PORT=8080
SUPERUSERS=["机器人管理号"]
# Sentry DSN 网址,如果不使用可以留空
SENTRY_DSN=
# Github OAuth App 配置,留空将功能受限
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_SELF_HOST=
```
2. 使用 `docker-compose`
> `docker-compose.yml` 中的配置视情况修改,**如无必要请勿修改!**
```bash
docker-compose up -d
```
2. 启动
安装 `docker-compose` 并在目录下执行 `docker-compose up -d` 即可。

View File

@ -10,23 +10,22 @@ services:
- bot_net
restart: always
nonebot:
build: .
image: cscs181/qq-github-bot:latest # docker hub
# image: ghcr.io/cscs181/qq-github-bot:latest # github image mirror
# build: . # use "build" instead of "image" if you want to build the image yourself
container_name: bot
# volumes:
# - "/etc/timezone:/etc/timezone:ro"
# - "/etc/localtime:/etc/localtime:ro"
# - "./.env:/app/.env.prod" # replace "./.env" with your own config file
ports:
- "$PORT:$PORT"
# you can load config file by "env_file"
env_file:
- "./.env"
environment:
- ENVIRONMENT=prod
- HOST=$HOST
- PORT=$PORT
- MAX_WORKERS=1
- APP_MODULE=bot:app
# - SECRET=$SECRET
# - ACCESS_TOKEN=$ACCESS_TOKEN
- XVFB_INSTALLED=true
- REDIS_HOST=bot_redis
- REDIS_PORT=6379
networks: