FROM python:3.11-slim # System dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg git \ && rm -rf /var/lib/apt/lists/* # Setup user for Hugging Face (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 dependencies 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 \ gunicorn \ huggingface_hub>=0.27.0 \ edge-tts # Copy files and create image directory COPY --chown=user:user . . RUN mkdir -p /home/user/app/img EXPOSE 7860 # Start with Gunicorn for better stability CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app", "--timeout", "120"]