FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 # Set environment variables ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PORT=7860 \ BASE_DIR=/app # Install Python and other dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ python3 \ python3-pip \ python3-dev \ build-essential \ git \ gcc \ g++ \ make \ curl \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Create necessary directories RUN mkdir -p /app/data/pdfs /app/data/texts /app/data/index # Copy requirements first for better caching COPY requirements.txt . # Install Python packages RUN pip3 install --no-cache-dir -r requirements.txt RUN pip3 install --no-cache-dir gradio # Copy your application code and data COPY app/ /app/ COPY data/ /app/data/ # Create a simple Gradio interface for the API COPY spaces_app.py /app/ # Expose the port Hugging Face Spaces expects EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:${PORT}/health || exit 1 # Command to run the application CMD ["python3", "spaces_app.py"]