rabiyulfahim commited on
Commit
be0722d
·
verified ·
1 Parent(s): 3b5d156

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -19
Dockerfile CHANGED
@@ -1,10 +1,10 @@
1
- # Use lightweight Python base image
2
  FROM python:3.10-slim
3
 
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,25 +14,13 @@ RUN pip install --no-cache-dir -r requirements.txt
14
  # Copy application code
15
  COPY . .
16
 
17
- # Hugging Face cache directory (use /tmp, writable in Spaces)
18
- # ENV HF_HOME=/tmp
19
- # ✅ Hugging Face cache directory (writable path)
20
  ENV HF_HOME=/app/.cache/huggingface
 
21
  RUN mkdir -p /app/.cache/huggingface
22
 
23
- # Pre-download model into /tmp to avoid cold start
24
- # RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
25
- # model_id='rabiyulfahim/qa_python_gpt2'; \
26
- # AutoTokenizer.from_pretrained(model_id, cache_dir='/tmp'); \
27
- # AutoModelForCausalLM.from_pretrained(model_id, cache_dir='/tmp')"
28
- # Pre-download model into /tmp to avoid cold start
29
- RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; \
30
- model_id='deepseek-ai/DeepSeek-R1'; \
31
- AutoTokenizer.from_pretrained(model_id, cache_dir='/app/.cache/huggingface'); \
32
- AutoModelForCausalLM.from_pretrained(model_id, cache_dir='/app/.cache/huggingface')"
33
-
34
- # Expose the correct port (Hugging Face default is 7860)
35
  EXPOSE 7860
36
 
37
- # Command to run the app
38
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use lightweight Python image
2
  FROM python:3.10-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies
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
 
 
18
  ENV HF_HOME=/app/.cache/huggingface
19
+ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
20
  RUN mkdir -p /app/.cache/huggingface
21
 
22
+ # Expose FastAPI port
 
 
 
 
 
 
 
 
 
 
 
23
  EXPOSE 7860
24
 
25
+ # Command to run FastAPI app
26
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]