# ───────────────────────────────────────────────────────────────────────────── # 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"]