Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +15 -6
Dockerfile
CHANGED
|
@@ -2,21 +2,30 @@ FROM python:3.10
|
|
| 2 |
|
| 3 |
WORKDIR /code
|
| 4 |
|
| 5 |
-
# Create cache directories with proper permissions
|
| 6 |
RUN mkdir -p /tmp/cache/huggingface && \
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
# Set environment variables for cache directories
|
| 10 |
ENV HF_HOME=/tmp/cache/huggingface
|
| 11 |
-
ENV TRANSFORMERS_CACHE=/tmp/cache/
|
| 12 |
-
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/cache/
|
|
|
|
|
|
|
| 13 |
|
| 14 |
COPY ./requirements.txt /code/requirements.txt
|
| 15 |
|
| 16 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 17 |
|
| 18 |
-
# Pre-download the sentence transformer model during build
|
| 19 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
COPY . /code
|
| 22 |
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /code
|
| 4 |
|
| 5 |
+
# Create cache directories with proper permissions and ownership
|
| 6 |
RUN mkdir -p /tmp/cache/huggingface && \
|
| 7 |
+
mkdir -p /tmp/cache/transformers && \
|
| 8 |
+
mkdir -p /tmp/cache/sentence_transformers && \
|
| 9 |
+
chmod -R 777 /tmp/cache && \
|
| 10 |
+
chown -R 1000:1000 /tmp/cache
|
| 11 |
|
| 12 |
# Set environment variables for cache directories
|
| 13 |
ENV HF_HOME=/tmp/cache/huggingface
|
| 14 |
+
ENV TRANSFORMERS_CACHE=/tmp/cache/transformers
|
| 15 |
+
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/cache/sentence_transformers
|
| 16 |
+
ENV TORCH_HOME=/tmp/cache/torch
|
| 17 |
+
ENV XDG_CACHE_HOME=/tmp/cache
|
| 18 |
|
| 19 |
COPY ./requirements.txt /code/requirements.txt
|
| 20 |
|
| 21 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 22 |
|
| 23 |
+
# Pre-download the sentence transformer model during build with proper cache setup
|
| 24 |
+
RUN export HF_HOME=/tmp/cache/huggingface && \
|
| 25 |
+
export TRANSFORMERS_CACHE=/tmp/cache/transformers && \
|
| 26 |
+
export SENTENCE_TRANSFORMERS_HOME=/tmp/cache/sentence_transformers && \
|
| 27 |
+
python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')" && \
|
| 28 |
+
chmod -R 777 /tmp/cache
|
| 29 |
|
| 30 |
COPY . /code
|
| 31 |
|