nvtitan/graphRAG
0
1# GraphLLM - Hugging Face Spaces Deployment2# Optimized Docker image for HF Spaces3 4FROM python:3.12-slim5 6# Set environment variables7ENV PYTHONUNBUFFERED=1 \8 PYTHONDONTWRITEBYTECODE=1 \9 PIP_NO_CACHE_DIR=1 \10 PIP_DISABLE_PIP_VERSION_CHECK=1 \11 DEBIAN_FRONTEND=noninteractive \12 API_PORT=7860 \13 HF_HOME=/app/cache \14 TRANSFORMERS_CACHE=/app/cache \15 SENTENCE_TRANSFORMERS_HOME=/app/cache16 17# Set working directory18WORKDIR /app19 20# Install system dependencies (minimal set for HF Spaces)21RUN apt-get update && apt-get install -y --no-install-recommends \22 build-essential \23 curl \24 tesseract-ocr \25 ghostscript \26 && rm -rf /var/lib/apt/lists/* \27 && apt-get clean28 29# Copy requirements first (for better layer caching)30COPY requirements.txt .31 32# Install Python dependencies33RUN pip install --no-cache-dir -r requirements.txt34 35# Copy application code36COPY . .37 38# Create data directories with proper permissions (777 for HF Spaces non-root user)39RUN mkdir -p data uploads logs cache data/faiss_index && \40 chmod -R 777 data uploads logs cache41 42# Expose Hugging Face Spaces default port43EXPOSE 786044 45# Health check46HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \47 CMD curl -f http://localhost:7860/ || exit 148 49# Run the application50# HF Spaces expects the app to listen on 0.0.0.0:786051CMD ["python3", "main.py"]52 