feat: 容器启动脚本 scripts/start.sh——幂等卸载 opencv-python(GUI 版缺 X11 库致 OCR 崩)并装 headless,compose 指向本脚本后环境修复全走 git
This commit is contained in:
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
# 容器启动脚本:环境修复 + 安装依赖 + 启动 web_server。
|
||||
# compose 的 python-app / python-app-main 服务 command 指向本脚本。
|
||||
#
|
||||
# 为什么需要环境修复:
|
||||
# opencv-python(GUI 版)依赖 X11 库(libxcb),python:slim 容器里 import cv2
|
||||
# 直接崩溃 → RapidOCR 不可用 → 条件判断的 OCR 步骤抛异常 → 任务失败退出。
|
||||
# 这里幂等卸载 GUI 版并保证安装 headless 版(本地 Mac 有 GUI 环境不受影响)。
|
||||
pip uninstall -y -q opencv-python 2>/dev/null || true
|
||||
|
||||
if [ -f requirements.txt ]; then
|
||||
pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
||||
fi
|
||||
|
||||
exec python -u web_server.py
|
||||
Reference in New Issue
Block a user