sss / Dockerfile
brucever's picture
Update Dockerfile
2471c51 verified
raw
history blame contribute delete
699 Bytes
FROM python:3.9
# 1. 创建用户
RUN useradd -m -u 1000 user
# 2. 切换 root 安装系统级 Chromium
# 这里我们一次性把所有可能的依赖库全装上,防止 127 错误
USER root
RUN apt-get update && apt-get install -y \
chromium \
chromium-driver \
libnss3 \
libgconf-2-4 \
libfontconfig1 \
&& rm -rf /var/lib/apt/lists/*
# 3. 切换回用户
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# 4. 安装依赖 (读取刚才修改的 requirements.txt)
COPY --chown=user requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# 5. 复制脚本
COPY --chown=user app.py /app/app.py
CMD ["python", "app.py"]