crawler_81tv/Dockerfile

44 lines
1.3 KiB
Docker
Raw 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.

# 使用官方Python基础镜像
FROM python:3.9-bookworm
# 设置工作目录
WORKDIR /app
# 设置时区(可选)
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 使用阿里云镜像源(完全替换所有源)
RUN rm -f /etc/apt/sources.list.d/* && \
echo "deb https://mirrors.aliyun.com/debian/ bookworm main contrib non-free non-free-firmware" > /etc/apt/sources.list && \
echo "deb https://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list && \
echo "deb https://mirrors.aliyun.com/debian-security bookworm-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list
# 安装系统依赖
RUN apt-get update && apt-get install -y \
gcc \
python3-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# 复制requirements.txt并安装Python依赖使用阿里pip源
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
-i https://mirrors.aliyun.com/pypi/simple/ \
--trusted-host mirrors.aliyun.com
# 复制项目文件
COPY . .
# 创建数据目录
RUN mkdir -p /app/data
# 暴露端口
EXPOSE 8000
# 设置环境变量
ENV PYTHONPATH=/app
ENV DATABASE_URL=sqlite:////app/data/videos.db
# 启动命令
CMD ["python", "main.py"]