# Universal Fast Dubbing - FastAPI Docker 配置(性能优化版) FROM python:3.11-slim # 设置工作目录 WORKDIR /app # 安装系统依赖(优化版本) RUN apt-get update && apt-get install -y \ ffmpeg \ --no-install-recommends \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean # 复制并安装Python依赖(利用Docker缓存) COPY backend/requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # 复制应用代码 COPY . . # 创建临时目录 RUN mkdir -p temp/gateway temp/processing temp/tts temp/sync temp/downloads # 设置环境变量(性能优化) ENV PYTHONPATH=/app/backend ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV UVICORN_WORKERS=1 ENV UVICORN_WORKER_CLASS=uvicorn.workers.UvicornWorker # 暴露端口 EXPOSE 7860 # 健康检查(使用现有的API端点) HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/api/status || exit 1 # 启动命令(使用完整版应用) CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1", "--access-log"]