FROM python:3.11-slim # HF Spaces best practice: non-root user + writable cache dirs ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_NO_CACHE_DIR=1 \ HF_HOME=/tmp/huggingface \ HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub WORKDIR /app RUN pip install --upgrade pip COPY requirements.txt /app/requirements.txt RUN pip install -r /app/requirements.txt COPY . /app # HF Spaces reserves port 7860 ENV PORT=7860 EXPOSE 7860 CMD ["python", "-m", "uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]