File size: 1,276 Bytes
a2543e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
FROM python:3.11-slim

WORKDIR /app

ENV TRANSFORMERS_CACHE=/tmp/cache
ENV HF_HOME=/tmp/cache
ENV TORCH_HOME=/tmp/cache
ENV EASYOCR_MODULE_PATH=/tmp/cache
ENV PYTHONUNBUFFERED=1

RUN mkdir -p /tmp/cache && chmod 777 /tmp/cache

RUN apt-get update && apt-get install -y \
    libgl1 libglib2.0-0 libsm6 libxext6 libxrender-dev libgomp1 \
    poppler-utils tesseract-ocr tesseract-ocr-eng libmagic1 \
    git git-lfs curl wget && \
    rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

RUN python -c "import easyocr; easyocr.Reader(['en'], gpu=False, download_enabled=True)"

COPY app/ ./app/

# Download NER model from your HuggingFace repo
RUN mkdir -p models/radiolo_clinic_ner && \
    git clone https://huggingface.co/MakPr016/clinical-ner-model models/radiolo_clinic_ner && \
    echo "✓ NER model downloaded from HuggingFace"

ENV HOST=0.0.0.0
ENV PORT=7860
ENV LAB_NER_MODEL_PATH=/app/models/radiolo_clinic_ner

RUN mkdir -p logs

EXPOSE 7860

HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]