Spaces:
Runtime error
Runtime error
File size: 1,056 Bytes
2457fea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 使用官方的Python基础镜像
FROM python:3.9-slim
# 设置工作目录
WORKDIR /code
# 更新软件包列表并安装Playwright所需的系统依赖
# 这步是关键,解决了默认环境下“缺少系统依赖”的问题
RUN apt-get update && apt-get install -y \
libnss3 \
libnspr4 \
libdbus-1-3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libxkbcommon-x11-0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
libxshmfence1 \
--no-install-recommends
# 复制Python依赖文件
COPY requirements.txt .
# 安装Python依赖
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# 安装Playwright的浏览器。这步会在构建镜像时执行,而不是每次启动时。
# 这解决了“启动慢”的问题。
RUN playwright install --with-deps chromium
# 复制你的应用代码
COPY . .
# 设置Streamlit的端口和启动命令
EXPOSE 8501
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"] |