feat: 添加 Docker 部署支持和 MCP 原生集成
- 添加 Dockerfile、docker-compose.yml 和 Jenkins 流水线配置 - 新增 MCP 原生集成模块 (mcp_native.py) - 移除旧的 mcp_bridge.py,更新依赖和文档 - 添加部署文档 (Docker 和服务器部署指南) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+29
-3
@@ -5,6 +5,7 @@ set -euo pipefail
|
||||
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
BACKEND_PORT=8000
|
||||
FRONTEND_PORT=5173
|
||||
VENV_PYTHON="$ROOT_DIR/.venv/bin/python"
|
||||
|
||||
require_file() {
|
||||
local path="$1"
|
||||
@@ -25,6 +26,26 @@ require_command() {
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_venv() {
|
||||
if [[ ! -x "$VENV_PYTHON" ]]; then
|
||||
echo "创建 Python 虚拟环境 (.venv)..."
|
||||
require_command python3
|
||||
python3 -m venv "$ROOT_DIR/.venv"
|
||||
fi
|
||||
|
||||
if ! "$VENV_PYTHON" -c "import fastapi, mcp, uvicorn" >/dev/null 2>&1; then
|
||||
echo "安装/更新 Python 依赖 (requirements.txt)..."
|
||||
"$VENV_PYTHON" -m pip install -r "$ROOT_DIR/requirements.txt"
|
||||
fi
|
||||
|
||||
if ! "$VENV_PYTHON" -c "import fastapi, mcp, uvicorn" >/dev/null 2>&1; then
|
||||
echo "Python 依赖安装失败,请检查网络或手动执行:"
|
||||
echo " $VENV_PYTHON -m pip install -r requirements.txt"
|
||||
read -r -k 1 "?按任意键关闭..."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
is_port_listening() {
|
||||
local port="$1"
|
||||
lsof -iTCP:"$port" -sTCP:LISTEN -t >/dev/null 2>&1
|
||||
@@ -70,13 +91,15 @@ end run
|
||||
APPLESCRIPT
|
||||
}
|
||||
|
||||
require_file "$ROOT_DIR/.venv/bin/python" "未找到 Python 虚拟环境: .venv/bin/python"
|
||||
require_file "$ROOT_DIR/frontend-admin/package.json" "未找到前端工程: frontend-admin/package.json"
|
||||
require_file "$ROOT_DIR/requirements.txt" "未找到 requirements.txt"
|
||||
require_command npm
|
||||
require_command curl
|
||||
require_command lsof
|
||||
require_command osascript
|
||||
|
||||
ensure_venv
|
||||
|
||||
if ! is_port_listening "$BACKEND_PORT"; then
|
||||
echo "启动后端..."
|
||||
open_backend_terminal
|
||||
@@ -93,14 +116,16 @@ fi
|
||||
|
||||
echo "等待服务就绪..."
|
||||
|
||||
if ! wait_for_http "http://127.0.0.1:$BACKEND_PORT/health" 30; then
|
||||
if ! wait_for_http "http://127.0.0.1:$BACKEND_PORT/health" 45; then
|
||||
echo "后端启动失败,请检查新打开的 Terminal 窗口"
|
||||
echo "常见原因: 依赖未装全 → 执行: .venv/bin/python -m pip install -r requirements.txt"
|
||||
read -r -k 1 "?按任意键关闭..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! wait_for_http "http://127.0.0.1:$FRONTEND_PORT/" 30; then
|
||||
if ! wait_for_http "http://127.0.0.1:$FRONTEND_PORT/" 45; then
|
||||
echo "前端启动失败,请检查新打开的 Terminal 窗口"
|
||||
echo "常见原因: 未 npm install → 在 frontend-admin 目录执行 npm install"
|
||||
read -r -k 1 "?按任意键关闭..."
|
||||
exit 1
|
||||
fi
|
||||
@@ -111,5 +136,6 @@ echo
|
||||
echo "启动成功"
|
||||
echo "前端: http://127.0.0.1:$FRONTEND_PORT/"
|
||||
echo "后端: http://127.0.0.1:$BACKEND_PORT/"
|
||||
echo "MCP: http://127.0.0.1:$BACKEND_PORT/mcp"
|
||||
echo
|
||||
read -r -k 1 "?按任意键关闭..."
|
||||
|
||||
Reference in New Issue
Block a user