Sherwinj10/ai-knowledge-base
0
1# Use Python 3.10 slim2FROM python:3.10-slim3 4# 1. Install system tools explicitly5# 'build-essential' and 'python3-dev' prevent the build from hanging 6# when installing chromadb and other C++ based libraries.7RUN apt-get update && apt-get install -y \8 build-essential \9 python3-dev \10 gcc \11 && rm -rf /var/lib/apt/lists/*12 13WORKDIR /app14 15# Copy backend requirements16COPY backend/requirements.txt .17 18# 2. Upgrade pip19RUN pip install --no-cache-dir --upgrade pip20 21# 3. CRITICAL SPEED FIX: Install PyTorch CPU version FIRST22# This downloads ~150MB instead of 2.5GB. 23# We do this BEFORE the main requirements to prevent conflicts.24RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu25 26# 4. Install the rest of the dependencies27RUN pip install --no-cache-dir -r requirements.txt28 29# Copy the rest of the application30COPY . .31 32# Create a writable directory for ChromaDB (required for HF Spaces)33RUN mkdir -p /app/chroma_db && chmod 777 /app/chroma_db34 35# Expose the port36EXPOSE 786037 38# Run the application39CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860"]