Files
zgene 6bed393c12
Backend Tests / backend-unit-test (push) Has been cancelled
Backend Tests / benchmark-test (push) Has been cancelled
CI@main / Node.js v22 (ubuntu-latest) (push) Has been cancelled
Thrift Syntax Validation / validate-thrift (push) Has been cancelled
License Check / License Check (push) Has been cancelled
first commit
2026-05-14 13:29:56 +08:00

60 lines
1.8 KiB
Bash
Executable File

#!/bin/sh # 改为sh,兼容busybox
# 手动指定容器内的固定路径(避免动态计算出错)
BASE_DIR="/app"
BACKEND_DIR="$BASE_DIR/backend"
BIN_DIR="$BASE_DIR/bin"
VENV_DIR="$BIN_DIR/.venv"
echo "Checking for Python virtual environment under $BIN_DIR"
if [ ! -f "$VENV_DIR/bin/activate" ]; then
echo "Virtual environment not found or incomplete. Re-creating..."
rm -rf "$VENV_DIR"
python3 -m venv "$VENV_DIR"
if [ $? -ne 0 ]; then
echo "Failed to create virtual environment - aborting startup"
exit 1
fi
echo "Virtual environment created successfully!"
else
echo "Virtual environment already exists. Skipping creation."
fi
echo "Installing required Python packages"
# 兼容sh的source语法
. "$VENV_DIR/bin/activate"
pip install --upgrade pip
# 原有依赖
pip install urllib3==1.26.16
pip install h11==0.16.0 httpx==0.28.1 pillow==11.2.1 pdfplumber==0.11.7 python-docx==1.2.0 numpy==2.3.1
# minio依赖
pip install minio==7.2.0
if [ $? -ne 0 ]; then
echo "Failed to install Python packages - aborting startup"
deactivate
exit 1
fi
echo "Python packages installed successfully!"
deactivate
# ========== 关键修复:跳过不存在的解析器脚本复制(核心!) ==========
# 原因:容器内可能没有backend源码,解析器脚本已通过宿主机挂载到bin目录
echo "⚠️ Skipping parser script copy (already mounted from host)"
# ========== 验证依赖安装 ==========
echo "Verifying installed packages..."
. "$VENV_DIR/bin/activate"
python3 -c "import minio; print('✅ minio library loaded successfully')"
if [ $? -eq 0 ]; then
echo "✅ All required packages are installed and available"
else
echo "❌ minio library installation failed"
deactivate
exit 1
fi
deactivate