修正了部署脚本
parent
9079d82729
commit
c76d05edb4
|
|
@ -1,9 +1,9 @@
|
||||||
# ==================== 部署模式说明 ====================
|
# ==================== 部署模式说明 ====================
|
||||||
# 1. 默认 Docker 一体化部署(./start.sh / docker-compose.yml):
|
# 1. 默认 Docker 一体化部署(./start.sh / docker-compose.yml):
|
||||||
# 使用下方 MYSQL_* / REDIS_* 初始化内置 MySQL、Redis。
|
# 只使用当前文件(根目录 .env)和 Docker Compose 注入的环境变量,不读取 backend/.env。
|
||||||
# 2. 直接运行后端或外接中间件部署:
|
# 2. 直接运行后端或外接中间件部署:
|
||||||
# 后端现在也兼容读取当前文件中的 MYSQL_HOST / REDIS_HOST,
|
# 后端可读取当前文件中的 MYSQL_HOST / REDIS_HOST,
|
||||||
# 也可以使用 backend/.env 中的 DB_* / REDIS_* 配置。
|
# 也可改用 backend/.env 中的 DB_* / REDIS_* 配置。
|
||||||
|
|
||||||
# ==================== 数据库配置 ====================
|
# ==================== 数据库配置 ====================
|
||||||
# MySQL 初始化参数(Docker 内置 MySQL)。
|
# MySQL 初始化参数(Docker 内置 MySQL)。
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@ vim .env # 配置 BASE_URL、密码等
|
||||||
./start.sh
|
./start.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
说明:
|
||||||
|
- 完整 Docker 一体化部署不会读取 `backend/.env`
|
||||||
|
|
||||||
脚本会自动完成:
|
脚本会自动完成:
|
||||||
- ✅ 检查Docker依赖
|
- ✅ 检查Docker依赖
|
||||||
- ✅ 创建必要目录
|
- ✅ 创建必要目录
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ htmlcov/
|
||||||
logs/
|
logs/
|
||||||
|
|
||||||
# 环境变量
|
# 环境变量
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
.env.local
|
.env.local
|
||||||
.env.*.local
|
.env.*.local
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ def _resolve_dashscope_api_key() -> str:
|
||||||
audio_config = SystemConfigService.get_active_audio_model_config("asr") or {}
|
audio_config = SystemConfigService.get_active_audio_model_config("asr") or {}
|
||||||
api_key = str(audio_config.get("api_key") or "").strip()
|
api_key = str(audio_config.get("api_key") or "").strip()
|
||||||
if not api_key:
|
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
|
return api_key
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,20 @@ VOICEPRINT_DIR = USER_DIR
|
||||||
AVATAR_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:
|
def _load_env_file(dotenv_path: Path) -> None:
|
||||||
if dotenv_path.exists():
|
if dotenv_path.exists():
|
||||||
load_dotenv(dotenv_path=dotenv_path, override=False)
|
load_dotenv(dotenv_path=dotenv_path, override=False)
|
||||||
|
|
||||||
|
|
||||||
# 优先读取仓库根目录 .env,再读取 backend/.env;
|
# 非 Docker 本地运行时,兼容读取仓库根目录 .env 与 backend/.env;
|
||||||
# 已存在的环境变量(例如 Docker Compose 注入)保持最高优先级。
|
# Docker 容器内只使用显式注入的环境变量,避免意外读取镜像内的开发配置。
|
||||||
_load_env_file(REPO_DIR / ".env")
|
if not _is_running_in_docker():
|
||||||
_load_env_file(BASE_DIR / ".env")
|
_load_env_file(REPO_DIR / ".env")
|
||||||
|
_load_env_file(BASE_DIR / ".env")
|
||||||
|
|
||||||
|
|
||||||
def _get_env(*names: str, default: str | None = None, allow_blank: bool = True) -> str | None:
|
def _get_env(*names: str, default: str | None = None, allow_blank: bool = True) -> str | None:
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class AsyncTranscriptionService:
|
||||||
if isinstance(api_key, str):
|
if isinstance(api_key, str):
|
||||||
api_key = api_key.strip()
|
api_key = api_key.strip()
|
||||||
if not api_key:
|
if not api_key:
|
||||||
raise Exception("未配置 DashScope API Key")
|
raise Exception("未在启用的 ASR 模型配置中设置 DashScope API Key")
|
||||||
return api_key
|
return api_key
|
||||||
|
|
||||||
def _build_dashscope_request_options(self, audio_config: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
def _build_dashscope_request_options(self, audio_config: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue