mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-16 03:55:26 +00:00
✨ Support Docker Compose
This commit is contained in:
parent
c99196843b
commit
30330aab3b
5
.gitignore
vendored
5
.gitignore
vendored
@ -41,6 +41,11 @@ plugins/genshin/daily/daily.json
|
||||
metadata/data/
|
||||
resources/assets/
|
||||
|
||||
### Docker ###
|
||||
redis_data/
|
||||
db_data/
|
||||
docker-compose.yml
|
||||
|
||||
### DotEnv ###
|
||||
.env
|
||||
|
||||
|
44
Dockerfile
44
Dockerfile
@ -1,18 +1,38 @@
|
||||
FROM python:3.10.8-slim-bullseye
|
||||
COPY . /app
|
||||
FROM python:3.10.10-buster
|
||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||
LANG=zh_CN.UTF-8 \
|
||||
SHELL=/bin/bash
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
WORKDIR /app
|
||||
RUN pip install virtualenv==20.16.6 poetry==1.2.2 \
|
||||
RUN echo "deb http://ftp.us.debian.org/debian buster main non-free" >> /etc/apt/sources.list.d/fonts.list \
|
||||
&& apt update \
|
||||
# clone
|
||||
&& apt install git wget curl -y \
|
||||
&& git clone -b main https://github.com/luoshuijs/TGPaimonBot.git /app \
|
||||
# install dependencies \
|
||||
&& pip install virtualenv==20.19.0 poetry==1.3.2 \
|
||||
&& python3 -m virtualenv venv/ \
|
||||
&& . venv/bin/activate \
|
||||
&& poetry config virtualenvs.create false \
|
||||
&& poetry source add --default mirrors https://pypi.tuna.tsinghua.edu.cn/simple/ \
|
||||
&& poetry install \
|
||||
&& poetry install --extras all \
|
||||
&& playwright install chromium \
|
||||
&& playwright install-deps \
|
||||
&& apt install -y git \
|
||||
&& git init . \
|
||||
&& git add -A \
|
||||
&& git -c user.name='user' \
|
||||
-c user.email='user@example.com' \
|
||||
commit -m 'Docker deployment' \
|
||||
&& playwright install-deps chromium \
|
||||
## set timezone
|
||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
||||
# create cache folder
|
||||
&& mkdir cache/ \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
ENTRYPOINT ["venv/bin/python", "./run.py"]
|
||||
# clean
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/* \
|
||||
~/.cache/pip \
|
||||
~/.cache/pypoetry \
|
||||
# Add the wait script to the image
|
||||
&& wget -O /wait https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait \
|
||||
&& chmod +x /wait
|
||||
ENTRYPOINT /wait && venv/bin/alembic upgrade head && venv/bin/python run.py
|
||||
|
52
README.md
52
README.md
@ -66,6 +66,58 @@ poetry run alembic upgrade head
|
||||
poetry run python ./run.py
|
||||
```
|
||||
|
||||
## 使用 Docker Compose
|
||||
|
||||
### 1. 安装 `docker` 和 `docker-compose`
|
||||
|
||||
```bash
|
||||
curl -fsSL https://get.docker.com | bash -s docker
|
||||
```
|
||||
|
||||
```bash
|
||||
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 chmod +x /usr/local/bin/docker-compose
|
||||
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
|
||||
docker-compose version
|
||||
```
|
||||
|
||||
### 2. 克隆项目
|
||||
|
||||
```bash
|
||||
git clone https://github.com/luoshuijs/TGPaimonBot.git
|
||||
cd TGPaimonBot
|
||||
```
|
||||
|
||||
### 3. 修改配置文件
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
cp docker-compose.gen.yml docker-compose.yml
|
||||
```
|
||||
|
||||
```dotenv
|
||||
# MySQL
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD="root"
|
||||
DB_DATABASE=paimon
|
||||
|
||||
# Redis
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
REDIS_DB=0
|
||||
REDIS_PASSWORD=""
|
||||
````
|
||||
|
||||
以及 bot token 等参数。
|
||||
|
||||
### 4. 运行
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## 其他说明
|
||||
|
||||
这个项目目前正在扩展,加入更多原神相关娱乐和信息查询功能,敬请期待。
|
||||
|
37
docker-compose.gen.yml
Normal file
37
docker-compose.gen.yml
Normal file
@ -0,0 +1,37 @@
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
restart: always
|
||||
volumes:
|
||||
- ./redis_data:/data
|
||||
logging:
|
||||
driver: none
|
||||
|
||||
mysql:
|
||||
image: ubuntu/mysql:8.0-22.04_beta
|
||||
restart: always
|
||||
volumes:
|
||||
- ./db_data:/var/lib/mysql
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=root
|
||||
- MYSQL_USER=root
|
||||
- MYSQL_DATABASE=paimon
|
||||
logging:
|
||||
driver: none
|
||||
|
||||
paimon:
|
||||
image: rtpaimon/tgpaimonbot:latest
|
||||
restart: always
|
||||
environment:
|
||||
- WAIT_HOSTS=mysql:3306, redis:6379
|
||||
depends_on:
|
||||
- redis
|
||||
- mysql
|
||||
volumes:
|
||||
- ./.env:/app/.env
|
||||
- ./cache:/app/cache
|
||||
- ./data:/app/data
|
||||
- ./logs:/app/logs
|
||||
- ./report:/app/report
|
Loading…
Reference in New Issue
Block a user