From b33ff17c26e153c6043408d9c81aa0794b40ded0 Mon Sep 17 00:00:00 2001 From: butubb <1422726308@qq.com> Date: Wed, 19 Aug 2026 16:14:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=B9=E5=99=A8=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=20scripts/start.sh=E2=80=94=E2=80=94?= =?UTF-8?q?=E5=B9=82=E7=AD=89=E5=8D=B8=E8=BD=BD=20opencv-python=EF=BC=88GU?= =?UTF-8?q?I=20=E7=89=88=E7=BC=BA=20X11=20=E5=BA=93=E8=87=B4=20OCR=20?= =?UTF-8?q?=E5=B4=A9=EF=BC=89=E5=B9=B6=E8=A3=85=20headless=EF=BC=8Ccompose?= =?UTF-8?q?=20=E6=8C=87=E5=90=91=E6=9C=AC=E8=84=9A=E6=9C=AC=E5=90=8E?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=BF=AE=E5=A4=8D=E5=85=A8=E8=B5=B0=20git?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/start.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 scripts/start.sh diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..e00095a --- /dev/null +++ b/scripts/start.sh @@ -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