# Use a Python 3.10 slim image FROM python:3.10-slim ENV TZ=UTC # Install system dependencies # libgl1 replaces libgl1-mesa-glx in newer Debian versions for OpenCV/MediaPipe RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ ffmpeg \ espeak \ && rm -rf /var/lib/apt/lists/* # Set up a new user named "user" with user ID 1000 (Required by Hugging Face) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # 1. Copy requirements first to leverage Docker caching # If your requirements.txt is inside a 'backend' folder, change this to: COPY --chown=user backend/requirements.txt . COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade -r requirements.txt # 2. Copy the rest of the files COPY --chown=user . . # 3. Start the application # If main.py is in the root of your Space, use: # CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"] # IF main.py is inside a 'backend' folder, use this instead: # CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]