Spaces:
Sleeping
Sleeping
File size: 1,088 Bytes
b5739f3 7d22da3 b5739f3 7d22da3 b5739f3 b2c8b36 | 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 | # ---- Base ----
FROM python:3.10-slim
# Set workdir
WORKDIR /app
ENV TRANSFORMERS_CACHE=/tmp/.cache
RUN mkdir -p /tmp/.cache && chmod -R 777 /tmp/.cache
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy project files (including data/ and faiss_index/)
COPY . /app
# Upgrade pip and install dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# ---- Pre-download MiniLM embeddings at build time ----
# The model will be stored in the default Hugging Face cache (~/.cache/huggingface)
RUN python -c "from langchain_community.embeddings import HuggingFaceEmbeddings; HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')"
COPY . .
# ---- Copy FAISS index to /tmp at runtime ----
# We'll copy them from /app/faiss_index in CMD, since /tmp is the only writable location in Spaces
# We will do this in an entrypoint script
# Expose port
EXPOSE 8000
# Run entrypoint
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|