FROM python:3.10-slim-bookworm
# calibre provides ebook-convert: docx/pdf/txt/rtf/odt/epub/mobi/azw3/html interop
RUN apt-get update \
    && apt-get install -y --no-install-recommends calibre ffmpeg fonts-wqy-zenhei \
    && rm -rf /var/lib/apt/lists/*
# audio tools: Piper (local neural TTS) + faster-whisper (local ASR)
# models are pre-downloaded on the host (build env has no internet)
RUN pip install --no-cache-dir piper-tts faster-whisper
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple "rembg[cpu]"
COPY hf-cache /root/.cache/huggingface
COPY piper-models /app/piper-models
# AI 图片: u2net 抠图模型(预下载) + waifu2x-ncnn-vulkan 无损放大(CPU)
COPY ai-models/u2net.onnx /root/.u2net/u2net.onnx
COPY waifu2x/waifu2x-ncnn-vulkan-20220728-ubuntu /app/waifu2x
WORKDIR /app
COPY server.py video_ops.py audio_ops.py mcp_ops.py .
ENV HF_HOME=/root/.cache/huggingface
EXPOSE 8091
CMD ["python", "server.py"]
