Spaces:
Sleeping
Sleeping
| # Use Python 3.9 slim image for efficiency | |
| FROM python:3.9-slim | |
| # Install build dependencies needed for ML packages (chromadb, sentence-transformers, blis) | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| python3-dev \ | |
| gcc \ | |
| g++ \ | |
| libc6-dev \ | |
| libffi-dev \ | |
| libssl-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a non-root user for security | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environment variables | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| ENV PYTHONPATH="/app:$PYTHONPATH" | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements file with proper ownership | |
| COPY --chown=user requirements.txt requirements.txt | |
| # Install Python dependencies with better wheel support | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \ | |
| pip install --no-cache-dir --prefer-binary --upgrade -r requirements.txt | |
| # Copy application code | |
| COPY --chown=user app.py /app/ | |
| COPY --chown=user . /app/ | |
| # Expose port 7860 for Hugging Face Spaces | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |