Files
aria2bot/Dockerfile
2025-12-15 16:10:00 +08:00

53 lines
1.2 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 阶段1: 构建依赖
FROM python:3.13-slim AS builder
# 安装 uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# 复制依赖文件
COPY pyproject.toml uv.lock ./
# 安装依赖到虚拟环境
RUN uv sync --frozen --no-dev --no-install-project
# 阶段2: 运行环境
FROM python:3.13-slim
LABEL maintainer="dnslin"
LABEL description="Aria2 Telegram Bot - 通过 Telegram 控制 aria2 下载"
# 安装必要工具aria2 通过 /install 命令下载)
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
WORKDIR /app
# 从构建阶段复制虚拟环境
COPY --from=builder /app/.venv /app/.venv
# 复制应用代码和入口脚本
COPY src/ ./src/
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
# 设置环境变量
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# 声明数据卷
VOLUME ["/root/downloads", "/root/.config/aria2"]
# 暴露 aria2 RPC 端口
EXPOSE 6800
# 启动命令
ENTRYPOINT ["./docker-entrypoint.sh"]