FROM python:3.11-slim # System deps RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg git \ && rm -rf /var/lib/apt/lists/* # HF Spaces requires uid 1000 RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" ENV HF_HOME="/home/user/.cache/huggingface" WORKDIR /home/user/app # Install Python deps — CPU-only torch to save memory RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu \ torch==2.6.0+cpu \ transformers>=4.49.0 \ accelerate>=1.3.0 \ flask==3.1.1 \ huggingface_hub>=0.27.0 \ edge-tts # Copy project files (includes app.py and img/ folder) COPY --chown=user:user . . # Make sure img dir exists even if empty (default.png must be inside) RUN mkdir -p /home/user/app/img EXPOSE 7860 CMD ["python", "app.py"]