FROM python:3.13-slim # Set environment variables ENV PYTHONUNBUFFERED=1 ENV PYTHONDONTWRITEBYTECODE=1 ENV GRADIO_SERVER_NAME=0.0.0.0 ENV GRADIO_SERVER_PORT=7860 # System dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ clang \ llvm-dev \ build-essential \ curl \ git \ pkg-config \ wget \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Create a non-root user for HuggingFace Spaces RUN useradd -m -u 1000 user WORKDIR /app # Copy requirements first for better caching COPY requirements.txt /app/requirements.txt # Install Python dependencies RUN pip install --no-cache-dir -r /app/requirements.txt && \ pip install --no-cache-dir libclang # Copy application code (excluding large data files) COPY --chown=user:user . /app # Set ownership RUN chown -R user:user /app # Switch to non-root user USER user # Expose the Gradio port EXPOSE 7860 # Default command - can be overridden to use --hf-dataset instead of --graph-file # To use HuggingFace dataset: --hf-dataset "username/dataset-name" # To use local file: --graph-file "/app/data/multihop_knowledge_graph_with_embeddings.json" CMD ["python", "-u", "gradio_mcp_space.py"]