chore: optimize local crawler image build

This commit is contained in:
hajimi
2026-08-01 17:01:29 +08:00
parent 9a83c8dfb7
commit 40619e2335
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -3,6 +3,7 @@ FROM python:3.11-slim-bookworm
ENV TZ=Asia/Shanghai \ ENV TZ=Asia/Shanghai \
PYTHONUNBUFFERED=1 \ PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \ PIP_NO_CACHE_DIR=1 \
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple \
DQD_CONFIG_PATH=/app/config/settings.yaml \ DQD_CONFIG_PATH=/app/config/settings.yaml \
DQD_TASKS_FILE=/app/config/crawler_tasks.yaml \ DQD_TASKS_FILE=/app/config/crawler_tasks.yaml \
DQD_LOCK_DIR=/app/data/locks DQD_LOCK_DIR=/app/data/locks
@@ -22,8 +23,10 @@ RUN apt-get update \
COPY requirements.txt /app/requirements.txt COPY requirements.txt /app/requirements.txt
RUN python -m pip install --upgrade pip setuptools wheel \ RUN python -m pip install --upgrade pip setuptools wheel \
&& python -m pip install -r /app/requirements.txt \ && python -m pip install -r /app/requirements.txt
&& python -m playwright install --with-deps chromium
# API 型采集任务不依赖 Chromium。浏览器型采集需要时再在镜像内单独安装,
# 避免本地首次构建因浏览器下载通道不可达而阻塞整个调度器。
COPY . /app COPY . /app
+1
View File
@@ -54,6 +54,7 @@
- 本地默认端口为 MySQL `3307`、Redis `6379`,均可通过 Compose 环境变量覆盖。 - 本地默认端口为 MySQL `3307`、Redis `6379`,均可通过 Compose 环境变量覆盖。
- 本地 `server/.env` 已切换为 Docker 网络内的 `mysql:3306``redis:6379`;该私有环境文件不入库、不影响测试服配置。 - 本地 `server/.env` 已切换为 Docker 网络内的 `mysql:3306``redis:6379`;该私有环境文件不入库、不影响测试服配置。
- 新增独立 `scheduler` 服务,每分钟执行一次 `php think crontab`;PHP-FPM 与定时任务进程保持隔离。`crawler` 类任务由命令自身跳过,仍应使用独立 crawler 容器调度。 - 新增独立 `scheduler` 服务,每分钟执行一次 `php think crontab`;PHP-FPM 与定时任务进程保持隔离。`crawler` 类任务由命令自身跳过,仍应使用独立 crawler 容器调度。
- 本地 crawler 私有环境文件 `docker/.env.docker` 已改为连接宿主机的 MySQL `3307` 与 Redis `6379`;crawler 镜像首次构建改为不强制下载 Chromium,以避免浏览器下载阻塞 API 型采集任务启动。当前镜像构建仍受 Docker 镜像网络连接阻塞,待网络恢复后执行 `docker compose -f docker/docker-compose.crawler.yml build crawler` 并启动服务。
- server 通过 Nginx 暴露在 `http://localhost:8000`,管理端与 H5 分别使用项目现有端口 `5176``5177`H5 本地开发 API 地址同步为 `http://localhost:8000` - server 通过 Nginx 暴露在 `http://localhost:8000`,管理端与 H5 分别使用项目现有端口 `5176``5177`H5 本地开发 API 地址同步为 `http://localhost:8000`
- 已完成容器启动与 HTTP 访问验证,三个入口均可正常响应。 - 已完成容器启动与 HTTP 访问验证,三个入口均可正常响应。