rabiyulfahim commited on
Commit
8d705bf
·
verified ·
1 Parent(s): 2e910dc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -7
Dockerfile CHANGED
@@ -4,7 +4,7 @@ FROM python:3.10-slim
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Install system dependencies (for PyTorch and git, sometimes needed)
8
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
9
 
10
  # Copy requirements and install
@@ -14,15 +14,14 @@ RUN pip install --no-cache-dir -r requirements.txt
14
  # Copy application code
15
  COPY . .
16
 
17
- # ✅ Hugging Face cache directory (writable in Spaces)
18
- ENV HF_HOME=/app/cache
19
- RUN mkdir -p /app/cache
20
 
21
- # Pre-download model so container starts faster
22
  RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
23
  model_id='rabiyulfahim/qa_python_gpt2'; \
24
- AutoTokenizer.from_pretrained(model_id, cache_dir='/app/cache'); \
25
- AutoModelForCausalLM.from_pretrained(model_id, cache_dir='/app/cache')"
26
 
27
  # Expose FastAPI port
28
  EXPOSE 8000
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies (for PyTorch and git)
8
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
9
 
10
  # Copy requirements and install
 
14
  # Copy application code
15
  COPY . .
16
 
17
+ # ✅ Hugging Face cache directory (use /tmp, writable in Spaces)
18
+ ENV HF_HOME=/tmp
 
19
 
20
+ # Pre-download model into /tmp to avoid cold start
21
  RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
22
  model_id='rabiyulfahim/qa_python_gpt2'; \
23
+ AutoTokenizer.from_pretrained(model_id, cache_dir='/tmp'); \
24
+ AutoModelForCausalLM.from_pretrained(model_id, cache_dir='/tmp')"
25
 
26
  # Expose FastAPI port
27
  EXPOSE 8000