youssefreda9 commited on
Commit
efcf9b4
·
1 Parent(s): dd64fe1

fix: Pre-download summarization model during Docker build (runtime has no DNS)

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -1
Dockerfile CHANGED
@@ -8,11 +8,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Copy requirements and install Python dependencies
11
- # Install CPU-only PyTorch first (saves ~1.5GB vs full torch)
12
  COPY requirements.txt .
13
  RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && \
14
  pip install --no-cache-dir -r requirements.txt
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Copy application code
17
  COPY src/ ./src/
18
  COPY .env* ./
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Copy requirements and install Python dependencies
11
+ # Install CPU-only PyTorch first (saves ~1.5GB vs full torch with CUDA)
12
  COPY requirements.txt .
13
  RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu && \
14
  pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Pre-download the summarization model during build (network is available here)
17
+ # At runtime, the container has NO outbound DNS, so models must be cached
18
+ RUN python -c "\
19
+ from transformers import MBartForConditionalGeneration, AutoTokenizer, AutoConfig; \
20
+ import torch; \
21
+ repo = 'bayan10/summarization-model'; \
22
+ print('Downloading tokenizer...'); \
23
+ AutoTokenizer.from_pretrained(repo); \
24
+ print('Downloading config...'); \
25
+ AutoConfig.from_pretrained(repo); \
26
+ print('Downloading model (float16)...'); \
27
+ MBartForConditionalGeneration.from_pretrained(repo, torch_dtype=torch.float16); \
28
+ print('Model cached successfully!'); \
29
+ "
30
+
31
  # Copy application code
32
  COPY src/ ./src/
33
  COPY .env* ./