Update Dockerfile
Browse files- Dockerfile +23 -4
Dockerfile
CHANGED
|
@@ -1,15 +1,34 @@
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
WORKDIR /app
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
COPY requirements.txt .
|
|
|
|
|
|
|
| 8 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
COPY . .
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
EXPOSE 7860
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
CMD ["
|
|
|
|
| 1 |
+
# Base image
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# Set working directory
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# System dependencies
|
| 8 |
+
RUN apt-get update && apt-get install -y git wget curl build-essential && rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# Copy requirements first (to leverage Docker cache)
|
| 11 |
COPY requirements.txt .
|
| 12 |
+
|
| 13 |
+
# Install Python deps
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
+
# Setup cache dir
|
| 17 |
+
ENV HF_HOME=/app/cache
|
| 18 |
+
ENV TRANSFORMERS_CACHE=/app/cache
|
| 19 |
+
ENV SENTENCE_TRANSFORMERS_HOME=/app/cache
|
| 20 |
+
|
| 21 |
+
# Pre-download model during build
|
| 22 |
+
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/clip-ViT-B-32', cache_folder='/app/cache')"
|
| 23 |
+
|
| 24 |
+
# Copy rest of the code
|
| 25 |
COPY . .
|
| 26 |
|
| 27 |
+
# Build FAISS index at image build time (optional, can be done once locally instead)
|
| 28 |
+
RUN python build_index.py
|
| 29 |
+
|
| 30 |
+
# Expose port
|
| 31 |
EXPOSE 7860
|
| 32 |
|
| 33 |
+
# Start API
|
| 34 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|