File size: 2,499 Bytes
236675e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ─────────────────────────────────────────────────────────────────────────────
# LexAI β€” Dockerfile for Hugging Face Spaces
# Only difference from local: port 7860 (required by HF Spaces)
# ─────────────────────────────────────────────────────────────────────────────

FROM python:3.11-slim

# ── System libraries ──────────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
        libgl1 \
        libglib2.0-0 \
        libgomp1 \
    && rm -rf /var/lib/apt/lists/*

# ── Working directory ─────────────────────────────────────────────────────────
WORKDIR /app

# ── Install Python dependencies ───────────────────────────────────────────────
COPY requirements.txt .
RUN sed 's/#.*//' requirements.txt > requirements_clean.txt \
    && pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir -r requirements_clean.txt

# ── Pre-download ML models at build time ─────────────────────────────────────
RUN python - <<'EOF'
from sentence_transformers import SentenceTransformer, CrossEncoder
SentenceTransformer("paraphrase-multilingual-MiniLM-L12-v2")
CrossEncoder("cross-encoder/mmarco-mMiniLMv2-L12-H384-v1")
print("Models downloaded successfully.")
EOF

# ── Copy application code ─────────────────────────────────────────────────────
COPY main.py .
COPY app/  ./app/
COPY static/ ./static/
COPY extracted_text_en.txt .

# ── HF Spaces requires port 7860 ─────────────────────────────────────────────
EXPOSE 7860

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