mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
添加docker-compose的sqllite部署方案,更适用于新手用户
优化Dockerfile文件,添加镜像源加速构建过程
This commit is contained in:
parent
6769c724cb
commit
0d37c28fa2
@ -13,7 +13,6 @@ tests/
|
||||
.gitignore
|
||||
.pre-commit-config.yaml
|
||||
.prettier*
|
||||
.env.dev
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
LICENSE
|
||||
|
||||
24
Dockerfile
24
Dockerfile
@ -4,8 +4,11 @@ WORKDIR /tmp
|
||||
|
||||
ENV POETRY_HOME="/opt/poetry" PATH="${PATH}:/opt/poetry/bin"
|
||||
|
||||
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/ && \
|
||||
pip install --upgrade pip
|
||||
|
||||
RUN curl -sSL https://install.python-poetry.org | python - -y && \
|
||||
poetry self add poetry-plugin-export
|
||||
poetry self add poetry-plugin-export
|
||||
|
||||
COPY ./pyproject.toml ./poetry.lock* /tmp/
|
||||
|
||||
@ -22,6 +25,8 @@ WORKDIR /wheel
|
||||
COPY --from=requirements-stage /tmp/requirements.txt /wheel/requirements.txt
|
||||
|
||||
# RUN python3 -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
|
||||
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/ && \
|
||||
pip install --upgrade pip
|
||||
|
||||
RUN pip wheel --wheel-dir=/wheel --no-cache-dir --requirement /wheel/requirements.txt
|
||||
|
||||
@ -44,12 +49,17 @@ ENV TZ=Asia/Shanghai PYTHONUNBUFFERED=1
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
RUN apt update && \
|
||||
apt install -y --no-install-recommends curl fontconfig fonts-noto-color-emoji \
|
||||
&& apt clean \
|
||||
&& fc-cache -fv \
|
||||
&& apt-get purge -y --auto-remove curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# 1. 确保目录存在
|
||||
RUN mkdir -p /etc/apt/sources.list.d
|
||||
# 2. 直接写入清华源(主源+安全源)
|
||||
RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free" >> /etc/apt/sources.list && \
|
||||
apt update && \
|
||||
apt install -y --no-install-recommends curl fontconfig fonts-noto-color-emoji && \
|
||||
apt clean && \
|
||||
fc-cache -fv && \
|
||||
apt-get purge -y --auto-remove curl && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 复制依赖项和应用代码
|
||||
COPY --from=build-stage /wheel /wheel
|
||||
|
||||
31
README.md
31
README.md
@ -143,6 +143,37 @@ poetry install # 安装依赖
|
||||
poetry run python bot.py
|
||||
```
|
||||
|
||||
## 🛠️ Docker-Compose部署(以SqlLite为例)
|
||||
|
||||
```bash
|
||||
# 获取代码
|
||||
git clone https://github.com/HibiKier/zhenxun_bot.git
|
||||
|
||||
# 修改.env.dev配置文件
|
||||
DB_URL = "sqlite:data/db/zhenxun.db" # 根据自行需求配置地址
|
||||
HOST = 0.0.0.0
|
||||
|
||||
# 进入目录
|
||||
cd zhenxun_bot
|
||||
|
||||
# 启动容器
|
||||
docker-compose -f docker-compose-sqllite.yml up -d
|
||||
# docker-compose -f docker-compose-sqllite.yml up -d --build(这个是重新构建镜像)
|
||||
|
||||
# 等待容器创建完成(中间可能由于后面的操作没有完成会一直自动重启)
|
||||
|
||||
# 容器创建成功后会在当前目录下创建一个DockerData目录
|
||||
# 创建目录/DockerData/data/db
|
||||
# 将/data/config.yaml文件复制到/DockerData/data/config.yaml
|
||||
# 配置/DockerData/data/config.yaml中的WebUI账号密码
|
||||
web-ui:
|
||||
USERNAME: admin
|
||||
PASSWORD:
|
||||
|
||||
# 重启容器等一下资源文件下载完成就可以打开WebUI了
|
||||
# 如果资源文件下载失败,可以手动下载到/DockerData/resources目录下
|
||||
```
|
||||
|
||||
## 📝 简单配置
|
||||
|
||||
> [!TIP]
|
||||
|
||||
15
docker-compose-sqllite.yml
Normal file
15
docker-compose-sqllite.yml
Normal file
@ -0,0 +1,15 @@
|
||||
services:
|
||||
zhenxun:
|
||||
image: zhenxun
|
||||
build: .
|
||||
container_name: zhenxun
|
||||
restart: unless-stopped
|
||||
privileged: true
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- $PWD/DockerData/data:/app/zhenxun/data
|
||||
- $PWD/DockerData/resources:/app/zhenxun/resources
|
||||
- $PWD/DockerData/log:/app/zhenxun/log
|
||||
tty: true
|
||||
stdin_open: true
|
||||
Loading…
Reference in New Issue
Block a user