FROM python:3.11-slim ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ PORT=7860 # HuggingFace Spaces requires writeable HOME; create a non-root user. RUN useradd -m -u 1000 user WORKDIR /app # Install dependencies first for better Docker layer caching. COPY --chown=user:user requirements.txt /app/requirements.txt RUN pip install --upgrade pip && pip install -r /app/requirements.txt # Copy the rest of the application. COPY --chown=user:user . /app USER user EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]