File size: 1,093 Bytes
382d16e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a5de0ec
 
 
66bf7a6
bffda7a
f24e651
66bf7a6
f24e651
66bf7a6
a5de0ec
382d16e
 
 
4a94b3a
382d16e
f24e651
bd403e3
382d16e
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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"]