修正了部署脚本

codex/dev
mula.liu 2026-04-13 17:46:10 +08:00
parent 9079d82729
commit c76d05edb4
6 changed files with 19 additions and 9 deletions

View File

@ -1,9 +1,9 @@
# ==================== 部署模式说明 ====================
# 1. 默认 Docker 一体化部署(./start.sh / docker-compose.yml
# 使用下方 MYSQL_* / REDIS_* 初始化内置 MySQL、Redis
# 只使用当前文件(根目录 .env和 Docker Compose 注入的环境变量,不读取 backend/.env
# 2. 直接运行后端或外接中间件部署:
# 后端现在也兼容读取当前文件中的 MYSQL_HOST / REDIS_HOST
# 也可以使用 backend/.env 中的 DB_* / REDIS_* 配置。
# 后端读取当前文件中的 MYSQL_HOST / REDIS_HOST
# 也可用 backend/.env 中的 DB_* / REDIS_* 配置。
# ==================== 数据库配置 ====================
# MySQL 初始化参数Docker 内置 MySQL

View File

@ -46,6 +46,9 @@ vim .env # 配置 BASE_URL、密码等
./start.sh
```
说明:
- 完整 Docker 一体化部署不会读取 `backend/.env`
脚本会自动完成:
- ✅ 检查Docker依赖
- ✅ 创建必要目录

View File

@ -41,6 +41,8 @@ htmlcov/
logs/
# 环境变量
.env
.env.*
.env.local
.env.*.local

View File

@ -17,7 +17,7 @@ def _resolve_dashscope_api_key() -> str:
audio_config = SystemConfigService.get_active_audio_model_config("asr") or {}
api_key = str(audio_config.get("api_key") or "").strip()
if not api_key:
raise HTTPException(status_code=500, detail="配置 DashScope API Key")
raise HTTPException(status_code=500, detail="在启用的 ASR 模型置中设置 DashScope API Key")
return api_key

View File

@ -19,13 +19,18 @@ VOICEPRINT_DIR = USER_DIR
AVATAR_DIR = USER_DIR
def _is_running_in_docker() -> bool:
return Path("/.dockerenv").exists()
def _load_env_file(dotenv_path: Path) -> None:
if dotenv_path.exists():
load_dotenv(dotenv_path=dotenv_path, override=False)
# 优先读取仓库根目录 .env再读取 backend/.env
# 已存在的环境变量(例如 Docker Compose 注入)保持最高优先级。
# 非 Docker 本地运行时,兼容读取仓库根目录 .env 与 backend/.env
# Docker 容器内只使用显式注入的环境变量,避免意外读取镜像内的开发配置。
if not _is_running_in_docker():
_load_env_file(REPO_DIR / ".env")
_load_env_file(BASE_DIR / ".env")

View File

@ -56,7 +56,7 @@ class AsyncTranscriptionService:
if isinstance(api_key, str):
api_key = api_key.strip()
if not api_key:
raise Exception("配置 DashScope API Key")
raise Exception("在启用的 ASR 模型置中设置 DashScope API Key")
return api_key
def _build_dashscope_request_options(self, audio_config: Optional[Dict[str, Any]] = None) -> Dict[str, Any]: