Spaces:
Sleeping
Sleeping
| # Use an official lightweight Python runtime | |
| FROM python:3.10-slim | |
| # Install light OS dependencies for matrix calculations or system libraries | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create user matching the Hugging Face Space security identity policy (User 1000) | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /app | |
| # Switch cache directories to safe, user-writable root spaces | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 \ | |
| HF_HOME=/home/user/.cache/huggingface | |
| # Copy instructions using accurate permission flags | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Bring code variables and model dependencies into build workspace | |
| COPY --chown=user . . | |
| # Adjust user context for active operations | |
| USER user | |
| # Hugging Face default external port mapping target | |
| EXPOSE 7860 | |
| # Serve via asynchronous production uvicorn thread engine | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |