Ethscriptions commited on
Commit
2457fea
·
verified ·
1 Parent(s): c24368c

Create Dockerfile

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