Update Dockerfile
Browse files- Dockerfile +17 -5
Dockerfile
CHANGED
@@ -2,6 +2,8 @@ FROM python:3.11-slim
|
|
2 |
|
3 |
# Set environment variables
|
4 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
5 |
|
6 |
# Install system dependencies
|
7 |
RUN apt-get update && apt-get install -y \
|
@@ -26,7 +28,7 @@ RUN apt-get update && apt-get install -y \
|
|
26 |
COPY requirements.txt .
|
27 |
RUN pip install --no-cache-dir -r requirements.txt
|
28 |
|
29 |
-
# Install additional
|
30 |
RUN pip install -U \
|
31 |
transformers \
|
32 |
sentence-transformers \
|
@@ -41,13 +43,23 @@ RUN pip install playwright && playwright install --with-deps chromium
|
|
41 |
COPY . /app
|
42 |
WORKDIR /app
|
43 |
|
44 |
-
#
|
|
|
|
|
|
|
|
|
45 |
RUN chmod -R 755 /app
|
46 |
|
47 |
-
# Preload SentenceTransformer model with
|
48 |
-
RUN python -c "
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
-
# Expose port
|
51 |
EXPOSE 7860
|
52 |
|
53 |
# Run the app
|
|
|
2 |
|
3 |
# Set environment variables
|
4 |
ENV PYTHONUNBUFFERED=1
|
5 |
+
ENV TRANSFORMERS_CACHE=/app/.cache
|
6 |
+
ENV HF_HOME=/app/.cache
|
7 |
|
8 |
# Install system dependencies
|
9 |
RUN apt-get update && apt-get install -y \
|
|
|
28 |
COPY requirements.txt .
|
29 |
RUN pip install --no-cache-dir -r requirements.txt
|
30 |
|
31 |
+
# Install additional libraries
|
32 |
RUN pip install -U \
|
33 |
transformers \
|
34 |
sentence-transformers \
|
|
|
43 |
COPY . /app
|
44 |
WORKDIR /app
|
45 |
|
46 |
+
# Create cache directory and set permissions
|
47 |
+
RUN mkdir -p /app/.cache && \
|
48 |
+
chmod -R 777 /app/.cache
|
49 |
+
|
50 |
+
# Set appropriate permissions for the entire app
|
51 |
RUN chmod -R 755 /app
|
52 |
|
53 |
+
# Preload SentenceTransformer model with explicit caching
|
54 |
+
RUN python -c "
|
55 |
+
import os
|
56 |
+
os.environ['TRANSFORMERS_CACHE'] = '/app/.cache'
|
57 |
+
os.environ['HF_HOME'] = '/app/.cache'
|
58 |
+
from sentence_transformers import SentenceTransformer
|
59 |
+
model = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2', cache_folder='/app/.cache')
|
60 |
+
"
|
61 |
|
62 |
+
# Expose port
|
63 |
EXPOSE 7860
|
64 |
|
65 |
# Run the app
|