# Use NVIDIA CUDA base for GPU support (HF Spaces provides T4 GPU) FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 # Set working directory WORKDIR /app # Install system dependencies (Python, git, etc.) RUN apt-get update && apt-get install -y \ python3.10 \ python3-pip \ git \ && rm -rf /var/lib/apt/lists/* # Upgrade pip RUN python3 -m pip install --upgrade pip # Set cache directories to writable /app/.cache (fixes PermissionError) ENV TRANSFORMERS_CACHE=/app/.cache/transformers ENV HF_HOME=/app/.cache/huggingface ENV HF_DATASETS_CACHE=/app/.cache/datasets ENV XDG_CACHE_HOME=/app/.cache RUN mkdir -p /app/.cache/transformers /app/.cache/huggingface /app/.cache/datasets RUN chmod -R 777 /app/.cache # Ensure full write access # Copy requirements and install Python deps (no cache to slim image) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy app code, db_helper, AND mcqs.json COPY app.py . COPY db_helper.py . COPY mcqs.json . EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]