Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Keep your existing environment optimizations (Excellent for GraphML processing) | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV OMP_NUM_THREADS=1 | |
| ENV MKL_NUM_THREADS=1 | |
| ENV OPENBLAS_NUM_THREADS=1 | |
| # 1. Create a non-root user with ID 1000 (REQUIRED for HF Spaces security) | |
| # This prevents permission errors when your app tries to write temp files. | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /app | |
| # 2. Set ownership of the working directory to the new user | |
| # This ensures the user can write to the local folder if needed. | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the code (including the 500MB graph) | |
| COPY --chown=user . . | |
| # Switch to the non-root user | |
| USER user | |
| # Add the local bin to PATH (for uvicorn) | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # 3. CRITICAL CHANGE: Port must be 7860 | |
| # Hugging Face Spaces strictly routes traffic to port 7860. | |
| # If you use 8080, your app will stay in "Building" forever. | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |