File size: 820 Bytes
e808cb9
 
 
 
 
 
97cfc10
 
 
e808cb9
 
 
 
 
 
 
 
 
fd681ee
 
 
e808cb9
 
 
 
 
 
 
 
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
# Use Python 3.12 slim image
FROM python:3.12-slim

# Set working directory
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 \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Pre-download the embedding model during build
RUN python -c "from langchain_community.embeddings import HuggingFaceEmbeddings; HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')"

# Copy all project files
COPY . .

# Expose port 7860 for Hugging Face Spaces
EXPOSE 7860

# Command to run your FastAPI app
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]