This commit is contained in:
mzl
2026-01-12 13:48:18 +08:00
parent 14f4d359b5
commit bfeec6d2db
2 changed files with 6 additions and 7 deletions
+5 -6
View File
@@ -1,7 +1,7 @@
FROM python:3.10-slim
# 安装系统依赖(包含 Git 和 Playwright 所需的所有库)
# 注意:这里手动安装所有 Chromium 运行所需的依赖,跳过 playwright install-deps
# 这一层会被缓存,除非 Dockerfile 改变
RUN apt-get update && apt-get install -y \
wget \
gnupg \
@@ -34,17 +34,16 @@ RUN apt-get update && apt-get install -y \
WORKDIR /app
# 复制依赖文件
# 复制依赖文件(这一层变化少,会被缓存)
COPY requirements.txt .
# 安装 Python 依赖
# 安装 Python 依赖(这一层也会被缓存)
RUN pip install --no-cache-dir -r requirements.txt
# 只安装 Playwright 浏览器二进制文件,跳过系统依赖安装
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=0 确保下载浏览器
# 安装 Playwright 浏览器(这一层也会被缓存)
RUN playwright install chromium
# 复制应用代码
# 复制应用代码(只有代码变化时才会重新执行后面层)
COPY . .
# 创建数据目录
+1 -1
View File
@@ -5,7 +5,7 @@ services:
build: .
container_name: xiaohongshu-scraper
ports:
- "18080:18080"
- "18081:18080" # 外部端口18081映射到容器内部18080
volumes:
# 持久化数据目录(采集结果、日志、登录状态)
- ./data:/app/data