Update Dockerfile
Browse files- Dockerfile +18 -6
Dockerfile
CHANGED
|
@@ -10,20 +10,32 @@ COPY requirements.txt .
|
|
| 10 |
# Step 4: Install the Python dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
|
|
|
| 13 |
RUN pip install --no-cache-dir faiss-gpu
|
| 14 |
|
| 15 |
-
# Step 5:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
COPY . .
|
| 17 |
|
| 18 |
-
# Step
|
| 19 |
-
# Copy the FAISS index and other model files explicitly
|
| 20 |
COPY ./models /app/models
|
| 21 |
|
| 22 |
-
#
|
| 23 |
RUN chmod -R 755 /app
|
| 24 |
|
| 25 |
-
# Step
|
| 26 |
EXPOSE 7860
|
| 27 |
|
| 28 |
-
# Step
|
| 29 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|
|
|
|
| 10 |
# Step 4: Install the Python dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
+
# Install faiss-gpu separately
|
| 14 |
RUN pip install --no-cache-dir faiss-gpu
|
| 15 |
|
| 16 |
+
# Step 5: Create necessary cache directories for HuggingFace, Sentence Transformers, and Torch
|
| 17 |
+
RUN mkdir -p /app/.cache/huggingface/transformers \
|
| 18 |
+
/app/.cache/sentence_transformers \
|
| 19 |
+
/app/.cache/torch \
|
| 20 |
+
&& chmod -R 777 /app/.cache
|
| 21 |
+
|
| 22 |
+
# Step 6: Set environment variables to use the custom cache directories
|
| 23 |
+
ENV HF_HOME=/app/.cache/huggingface
|
| 24 |
+
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
|
| 25 |
+
ENV SENTENCE_TRANSFORMERS_HOME=/app/.cache/sentence_transformers
|
| 26 |
+
ENV TORCH_HOME=/app/.cache/torch
|
| 27 |
+
|
| 28 |
+
# Step 7: Copy the entire codebase into the container
|
| 29 |
COPY . .
|
| 30 |
|
| 31 |
+
# Step 8: Ensure FAISS index and other models are in the correct location
|
|
|
|
| 32 |
COPY ./models /app/models
|
| 33 |
|
| 34 |
+
# Step 9: Set permissions for the entire app directory
|
| 35 |
RUN chmod -R 755 /app
|
| 36 |
|
| 37 |
+
# Step 10: Expose the port that FastAPI will run on (default: 7860)
|
| 38 |
EXPOSE 7860
|
| 39 |
|
| 40 |
+
# Step 11: Set the entry point to run FastAPI with Uvicorn
|
| 41 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|