统一 Docker Compose 部署,并将客户端拆分为独立子项目。
移除宿主机/conda 启动脚本与 dev 联调工具,后端仅通过 docker compose 部署并默认启用 GPU。模拟客户端与语音确认页迁入 clients/ 下自包含目录,切断对后端源码路径的依赖。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
45
clients/voice-confirmation/scripts/bundle_single_html.py
Executable file
45
clients/voice-confirmation/scripts/bundle_single_html.py
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""将本目录下的 index.html + voice_app.js 打成单文件 dist/index.html。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import shutil
|
||||
import stat
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main() -> None:
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
index = root / "index.html"
|
||||
app_js = root / "voice_app.js"
|
||||
out_dir = root / "dist"
|
||||
out_file = out_dir / "index.html"
|
||||
if not index.is_file() or not app_js.is_file():
|
||||
raise SystemExit(f"missing {index} or {app_js}")
|
||||
html = index.read_text(encoding="utf-8")
|
||||
js = app_js.read_text(encoding="utf-8")
|
||||
pat = re.compile(
|
||||
r'<script\s+src=["\']voice_app\.js["\']\s+defer\s*>\s*</script>',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
if not pat.search(html):
|
||||
raise SystemExit("index.html must contain <script src=\"voice_app.js\" defer></script>")
|
||||
|
||||
def _repl(_m):
|
||||
return "<script defer>\n" + js + "\n</script>"
|
||||
|
||||
inlined = pat.sub(_repl, html, count=1)
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
out_file.write_text(inlined, encoding="utf-8")
|
||||
for name in ("start_http.sh", "start_http.bat"):
|
||||
src = root / name
|
||||
dst = out_dir / name
|
||||
shutil.copy2(src, dst)
|
||||
sh = out_dir / "start_http.sh"
|
||||
sh.chmod(sh.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
||||
print(f"wrote {out_file} (+ start_http.* in dist/)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user