Syncbuz120 commited on
Commit
6df633f
Β·
1 Parent(s): d30125c

new docker fix

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -6
Dockerfile CHANGED
@@ -15,19 +15,27 @@ RUN pip install --no-cache-dir -r requirements.txt
15
  RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
16
 
17
  # βœ… Set environment variables to a writable path
18
- ENV TRANSFORMERS_CACHE=/app/cache
19
  ENV HF_HOME=/app/cache
 
20
  ENV TOKENIZERS_PARALLELISM=false
21
  ENV OMP_NUM_THREADS=1
22
 
23
- # βœ… Create model cache directory inside app folder
24
- RUN mkdir -p /app/cache
25
 
26
  # Copy application
27
  COPY . .
28
 
29
- # βœ… Expose correct port for Hugging Face Spaces
 
 
 
 
 
 
 
 
30
  EXPOSE 7860
31
 
32
- # βœ… Run app on correct port
33
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
 
15
  RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
16
 
17
  # βœ… Set environment variables to a writable path
 
18
  ENV HF_HOME=/app/cache
19
+ ENV TRANSFORMERS_CACHE=/app/cache
20
  ENV TOKENIZERS_PARALLELISM=false
21
  ENV OMP_NUM_THREADS=1
22
 
23
+ # βœ… Create cache directory with proper permissions
24
+ RUN mkdir -p /app/cache && chmod -R 777 /app/cache
25
 
26
  # Copy application
27
  COPY . .
28
 
29
+ # βœ… Pre-download the model during build (optional but recommended)
30
+ RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
31
+ AutoTokenizer.from_pretrained('distilgpt2', cache_dir='/app/cache'); \
32
+ AutoModelForCausalLM.from_pretrained('distilgpt2', cache_dir='/app/cache')" || echo "Model download failed, will retry at runtime"
33
+
34
+ # βœ… Ensure cache directory is writable after model download
35
+ RUN chmod -R 777 /app/cache
36
+
37
+ # βœ… Expose correct port
38
  EXPOSE 7860
39
 
40
+ # βœ… Run app
41
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]