visqol / Dockerfile
clash-linux's picture
Upload 9 files
af28602 verified
# 使用官方 Python 3.8 镜像以匹配 .so 文件
FROM python:3.8-slim
# 设置工作目录
WORKDIR /app
# 安装系统依赖 (libsndfile1 用于 soundfile, ffmpeg 用于转换)
RUN apt-get update && apt-get install -y --no-install-recommends \
libsndfile1 \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 复制 ViSQOL 构建文件到容器中的 /app/build 目录下
# 注意:源路径相对于 Dockerfile 所在位置
COPY ./build /app/build
# 复制项目文件到容器中
COPY requirements.txt app.py ./
# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt
# 将 ViSQOL 库所在的目录添加到动态链接器查找路径
# 这样 Python 的 ctypes 或 CFFI 才能找到 .so 文件
ENV LD_LIBRARY_PATH=/app/build/visqol:${LD_LIBRARY_PATH}
# 确保 ViSQOL 库有执行权限 (虽然通常不需要对 .so 设置执行权限,但以防万一)
# RUN chmod +x /app/build/visqol/visqol_lib_py.so
# 暴露 FastAPI 默认使用的端口 (虽然 HF Spaces 会处理端口映射)
EXPOSE 8000
# 启动 FastAPI 应用
# 使用 uvicorn 运行 app.py 中的 app 实例
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]