Spaces:
Sleeping
Sleeping
File size: 1,808 Bytes
5acd81f |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# ==========================
# Base image
# ==========================
FROM python:3.11-slim
# ==========================
# System dependencies
# ==========================
RUN apt-get update && apt-get install -y --no-install-recommends \
tesseract-ocr \
tesseract-ocr-eng \
libtesseract-dev \
poppler-utils \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
ghostscript \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ==========================
# Set working directory
# ==========================
WORKDIR /app
# ==========================
# Install Python dependencies
# ==========================
COPY requirements.txt .
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# ==========================
# Copy app code
# ==========================
COPY . .
# ==========================
# Hugging Face cache setup
# ==========================
# Use /tmp/hf_cache because it's always writable on Hugging Face Spaces
ENV HF_HOME=/tmp/hf_cache \
TRANSFORMERS_CACHE=/tmp/hf_cache \
HF_DATASETS_CACHE=/tmp/hf_cache
RUN mkdir -p /app/uploads /app/summaries /app/embeddings /app/logs /tmp/hf_cache \
&& chmod -R 777 /app /tmp/hf_cache
# ==========================
# (Optional) Pre-download SentenceTransformer model
# Speeds up startup by caching during build
# ==========================
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
# ==========================
# Expose port
# ==========================
EXPOSE 7860
# ==========================
# Command to run FastAPI app
# ==========================
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|