-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (44 loc) · 1.18 KB
/
Dockerfile
File metadata and controls
53 lines (44 loc) · 1.18 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
FROM python:3.11-slim
WORKDIR /app
# 设置环境变量
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PLAYWRIGHT_HEADLESS=true
# 安装系统依赖(Playwright 需要)
RUN apt-get update -o Acquire::Check-Valid-Until=false || true && \
apt-get install -y --no-install-recommends --fix-missing \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libdbus-1-3 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
fonts-liberation \
libappindicator3-1 \
xdg-utils \
wget \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# 先复制依赖文件,利用Docker缓存层
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir playwright>=1.40.0
# 安装 Playwright 浏览器(会自动安装系统依赖)
RUN playwright install chromium
# 复制项目文件
COPY . .
# 创建必要的目录
RUN mkdir -p data tmp logs
EXPOSE 8000
# 使用python -m方式运行,更稳定
CMD ["python", "-u", "main.py"]
# Build trigger