mirror of
https://github.com/dnslin/aria2bot.git
synced 2026-01-11 04:02:20 +08:00
feat: 移除默认的aria2
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -18,11 +18,9 @@ FROM python:3.13-slim
|
|||||||
LABEL maintainer="dnslin"
|
LABEL maintainer="dnslin"
|
||||||
LABEL description="Aria2 Telegram Bot - 通过 Telegram 控制 aria2 下载"
|
LABEL description="Aria2 Telegram Bot - 通过 Telegram 控制 aria2 下载"
|
||||||
|
|
||||||
# 安装 aria2 和必要工具
|
# 安装必要工具(aria2 通过 /install 命令下载)
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends ca-certificates \
|
||||||
aria2 \
|
|
||||||
ca-certificates \
|
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
&& apt-get clean
|
&& apt-get clean
|
||||||
|
|
||||||
@@ -31,13 +29,13 @@ WORKDIR /app
|
|||||||
# 从构建阶段复制虚拟环境
|
# 从构建阶段复制虚拟环境
|
||||||
COPY --from=builder /app/.venv /app/.venv
|
COPY --from=builder /app/.venv /app/.venv
|
||||||
|
|
||||||
# 复制应用代码
|
# 复制应用代码和入口脚本
|
||||||
COPY src/ ./src/
|
COPY src/ ./src/
|
||||||
COPY main.py banner.txt ./
|
COPY main.py banner.txt docker-entrypoint.sh ./
|
||||||
|
RUN chmod +x docker-entrypoint.sh
|
||||||
|
|
||||||
# 创建必要目录和符号链接
|
# 创建必要目录
|
||||||
RUN mkdir -p /root/.local/bin /root/.config/aria2 /root/downloads && \
|
RUN mkdir -p /root/.local/bin /root/.config/aria2 /root/downloads
|
||||||
ln -s /usr/bin/aria2c /root/.local/bin/aria2c
|
|
||||||
|
|
||||||
# 设置环境变量
|
# 设置环境变量
|
||||||
ENV PATH="/app/.venv/bin:$PATH"
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
@@ -51,4 +49,4 @@ VOLUME ["/root/downloads", "/root/.config/aria2"]
|
|||||||
EXPOSE 6800
|
EXPOSE 6800
|
||||||
|
|
||||||
# 启动命令
|
# 启动命令
|
||||||
CMD ["python", "main.py"]
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|
||||||
|
|||||||
8
docker-entrypoint.sh
Normal file
8
docker-entrypoint.sh
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Docker 容器入口脚本
|
||||||
|
|
||||||
|
# 创建必要目录
|
||||||
|
mkdir -p /root/.local/bin /root/.config/aria2 /root/downloads
|
||||||
|
|
||||||
|
# 启动应用
|
||||||
|
exec python main.py
|
||||||
@@ -257,10 +257,15 @@ class Aria2Installer:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if ARIA2_CONFIG_DIR.exists():
|
if ARIA2_CONFIG_DIR.exists():
|
||||||
shutil.rmtree(ARIA2_CONFIG_DIR)
|
# 删除配置目录中的文件,而不是整个目录(兼容 Docker 挂载卷)
|
||||||
logger.info(f"已删除配置目录: {ARIA2_CONFIG_DIR}")
|
for item in ARIA2_CONFIG_DIR.iterdir():
|
||||||
|
if item.is_file():
|
||||||
|
item.unlink()
|
||||||
|
elif item.is_dir():
|
||||||
|
shutil.rmtree(item)
|
||||||
|
logger.info(f"已清空配置目录: {ARIA2_CONFIG_DIR}")
|
||||||
except Exception as exc: # noqa: PERF203
|
except Exception as exc: # noqa: PERF203
|
||||||
logger.error(f"删除配置目录失败: {exc}")
|
logger.error(f"清空配置目录失败: {exc}")
|
||||||
errors.append(exc)
|
errors.append(exc)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user