alibidaran commited on
Commit
db4eca9
·
verified ·
1 Parent(s): 921de0f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -4
Dockerfile CHANGED
@@ -9,16 +9,19 @@ RUN apt-get update && apt-get install -y \
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Create a writable cache directory for Hugging Face
 
13
  ENV HF_HOME=/app/hf_cache
14
  ENV TRANSFORMERS_CACHE=/app/hf_cache
15
 
16
- # Copy requirements first (so Docker caches layers properly)
17
  COPY requirements.txt ./
18
-
19
  RUN pip3 install --no-cache-dir -r requirements.txt
20
 
21
- # Copy source code
 
 
 
22
  COPY src/ ./src/
23
 
24
  EXPOSE 8501
 
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create writable cache dir for Hugging Face
13
+ RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
14
  ENV HF_HOME=/app/hf_cache
15
  ENV TRANSFORMERS_CACHE=/app/hf_cache
16
 
17
+ # Copy requirements and install
18
  COPY requirements.txt ./
 
19
  RUN pip3 install --no-cache-dir -r requirements.txt
20
 
21
+ # Pre-download the SentenceTransformer model to avoid runtime PermissionError
22
+ RUN python3 -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2', cache_folder='/app/hf_cache')"
23
+
24
+ # Copy app source code
25
  COPY src/ ./src/
26
 
27
  EXPOSE 8501