Yashashvibhardwaj's picture
Update Dockerfile
37990d9 verified
raw
history blame
913 Bytes
# Base image
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# System dependencies
RUN apt-get update && apt-get install -y git wget curl build-essential && rm -rf /var/lib/apt/lists/*
# Copy requirements first (to leverage Docker cache)
COPY requirements.txt .
# Install Python deps
RUN pip install --no-cache-dir -r requirements.txt
# Setup cache dir
ENV HF_HOME=/app/cache
ENV TRANSFORMERS_CACHE=/app/cache
ENV SENTENCE_TRANSFORMERS_HOME=/app/cache
# Pre-download model during build
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/clip-ViT-B-32', cache_folder='/app/cache')"
# Copy rest of the code
COPY . .
# Build FAISS index at image build time (optional, can be done once locally instead)
RUN python build_index.py
# Expose port
EXPOSE 7860
# Start API
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]