Seth commited on
Commit
6dc7352
·
1 Parent(s): dfd15d5

Download model during Docker build to persist across restarts

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -0
Dockerfile CHANGED
@@ -14,6 +14,18 @@ WORKDIR /app
14
  COPY backend/requirements.txt /app/backend/requirements.txt
15
  RUN pip install --no-cache-dir -r /app/backend/requirements.txt
16
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  # Copy backend code
18
  COPY backend /app/backend
19
 
 
14
  COPY backend/requirements.txt /app/backend/requirements.txt
15
  RUN pip install --no-cache-dir -r /app/backend/requirements.txt
16
 
17
+ # Download and save model during build (so it persists across restarts)
18
+ # This prevents re-downloading the model on every container restart
19
+ RUN mkdir -p /app/Model/bert-tiny && \
20
+ python3 -c "from transformers import AutoTokenizer, AutoModel; \
21
+ print('Downloading BERT-tiny model during build...'); \
22
+ tokenizer = AutoTokenizer.from_pretrained('prajjwal1/bert-tiny'); \
23
+ model = AutoModel.from_pretrained('prajjwal1/bert-tiny'); \
24
+ print('Saving model to /app/Model/bert-tiny...'); \
25
+ tokenizer.save_pretrained('/app/Model/bert-tiny'); \
26
+ model.save_pretrained('/app/Model/bert-tiny'); \
27
+ print('Model saved successfully!')"
28
+
29
  # Copy backend code
30
  COPY backend /app/backend
31