Spaces:
Sleeping
Sleeping
File size: 1,247 Bytes
ff7b177 df7b1b9 ff7b177 d3a8deb df7b1b9 ff7b177 d3a8deb | 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 | # Use a slim Python base image
FROM python:3.12-slim
# Set the working directory in the container
WORKDIR /app
# Install system dependencies required for PyMuPDF (fitz)
# This is in a separate layer to leverage Docker's build cache.
RUN apt-get update && apt-get install -y --no-install-recommends \
libmupdf-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Install CPU-only PyTorch first — avoids pulling 2.5 GB CUDA build
# sentence-transformers depends on torch; without this it installs the full CUDA wheel
RUN pip install --no-cache-dir torch==2.5.1 --index-url https://download.pytorch.org/whl/cpu
# Copy the requirements file and install remaining Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download and cache the sentence transformer model.
# This ensures the model is ready on first boot and avoids download delays.
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
# Copy the application code into the container
COPY app/ ./app/
# Default port 8000 for local/Docker. HF Spaces overrides with PORT=7860.
ENV PORT=7860
EXPOSE 7860
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT}"]
|