File size: 1,076 Bytes
b6f9fa8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
# MediRAG Backend - Hugging Face Spaces Docker Deployment
# Optimized for faster builds
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies (libmupdf deps bundled in pymupdf wheel, no extra needed)
RUN apt-get update && apt-get install -y \
    git \
    curl \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
ENV HF_HOME=/tmp/hf_home
ENV TORCH_HOME=/tmp/torch_cache
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1

# Copy requirements first for better caching
COPY requirements_minimal.txt .

# Force pip re-run by busting the cache (update this date to force full reinstall)
ARG CACHE_BUST=2026-04-12-v3
RUN pip install --no-cache-dir -r requirements_minimal.txt

# Copy the rest of the application
COPY . .

# Create necessary directories
RUN mkdir -p data/processed data/raw logs

# Expose port (Hugging Face Spaces uses 7860)
EXPOSE 7860

# Run FastAPI backend directly
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]