Files
content-harvester/Dockerfile
T
huyue 497fae99c6 init: content-harvester —— 内容采集服务
FastAPI + Playwright(headed Chrome/xvfb 过 Cloudflare)抓内容详情页元数据;
可选把 m3u8 视频转 mp4 + 封面上传对象存储(配置由调用方下发,本服务不持密钥);
走主站 lobster 执行器契约(invoke/poll),回传 ResourceIngestItem 形式的 resources。
当前内置 xchina.co 的 scraper(core/scraper.py)。
2026-05-12 16:20:39 +08:00

33 lines
1.3 KiB
Docker

FROM mcr.microsoft.com/playwright/python:v1.44.0-jammy
WORKDIR /app
# xvfb: 让我们能跑「有头」Chrome —— Cloudflare 的 JS 质询对真实 headed 浏览器才会自动放行,
# 无头 chromium-headless-shell 会被一眼识破
# ffmpeg: yt-dlp 合并 m3u8 分片成 mp4 用
RUN apt-get update && apt-get install -y --no-install-recommends xvfb ffmpeg \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
# 注:Google Chrome 在 Linux arm64 上没有官方包,这里只装 Playwright 自带 Chromium。
# 在 x86_64 服务器上可改成 `playwright install chromium chrome` 并设 BROWSER_CHANNEL=chrome,
# 用真实 Chrome 通道对绕 Cloudflare 更有效。
RUN pip install --no-cache-dir -r requirements.txt \
&& python -m playwright install chromium
COPY core/ core/
COPY server/ server/
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# 持久浏览器资料目录(挂卷;可预置过了 Cloudflare 的 cf_clearance cookie)
ENV BROWSER_PROFILE_DIR=/data/browser_profile \
HEADLESS=0 \
BROWSER_CHANNEL= \
PYTHONUNBUFFERED=1
VOLUME ["/data/browser_profile"]
EXPOSE 8000
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "8000"]