# ClareVoice + React UI(产品版界面) # 从项目根目录构建(需包含 web/ 与 hf_space/ClareVoice/): # docker build -f hf_space/ClareVoice/Dockerfile.react . # 推送至 HF Space 后,在 Settings 中指定 Dockerfile 路径:hf_space/ClareVoice/Dockerfile.react # ========== 1) 构建前端 ========== FROM node:20-slim AS web_builder WORKDIR /web COPY web/package*.json ./ RUN npm install COPY web/ ./ RUN npm run build # ========== 2) 运行后端 ========== FROM python:3.11-slim WORKDIR /app RUN apt-get update && \ apt-get install -y --no-install-recommends libxcb1 libxcb-xinerama0 && \ rm -rf /var/lib/apt/lists/* RUN useradd -m -u 1000 user # ClareVoice 后端(不含 web 源码,避免 COPY . 覆盖下面的 web/build) COPY hf_space/ClareVoice/requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir "huggingface_hub>=1.3.0,<2.0" COPY hf_space/ClareVoice/ ./ COPY --from=web_builder --chown=user /web/build ./web/build USER user ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH EXPOSE 7860 CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]