Files
etf/Dockerfile_base

76 lines
1.8 KiB
Plaintext

FROM python:3.12-slim
# 设置工作目录
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y \
wget \
gnupg \
&& rm -rf /var/lib/apt/lists/*
# 安装Playwright的依赖
RUN apt-get update && apt-get install -y \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libdbus-1-3 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
&& rm -rf /var/lib/apt/lists/*
# 配置pip源
RUN mkdir -p /root/.pip && \
echo "[global]" > /root/.pip/pip.conf && \
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf && \
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /root/.pip/pip.conf
# 更新pip
RUN python -m pip install --upgrade pip
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
rm -rf /var/lib/apt/lists/*
RUN pip install uv \
&& rm -rf /root/.cache/pip
ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
# 复制依赖文件
COPY requirements.txt .
# 配置清华源并安装 Python 依赖
# RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
# pip install --only-binary=all --no-cache-dir -r requirements.txt
RUN uv pip install --system -r requirements.txt
# 预先安装 Playwright 的系统依赖
RUN apt-get update && apt-get install -y \
xvfb \
libopengl0 \
&& rm -rf /var/lib/apt/lists/*
# 安装Playwright浏览器
RUN playwright install chromium
RUN playwright install-deps
# 暴露端口
EXPOSE 80
# 运行应用
# CMD ["python", "update_data.py"]