Osama-Ahmed-27 commited on
Commit
1cc5250
·
verified ·
1 Parent(s): 213d749

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -20
Dockerfile CHANGED
@@ -1,39 +1,36 @@
1
  # Lightweight Python image
2
  FROM python:3.10-slim
3
 
4
- # System deps: ffmpeg (for Whisper), git + g++ (some wheels may need it)
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  ffmpeg git build-essential \
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
- # For faster HF model caching inside the container
10
- ENV TRANSFORMERS_CACHE=/root/.cache/huggingface/transformers
11
- ENV HF_HOME=/root/.cache/huggingface
12
- ENV PYTHONDONTWRITEBYTECODE=1
13
- ENV PYTHONUNBUFFERED=1
14
 
15
- # Optional: choose Whisper size via env (tiny/base/small/medium)
16
- # You can override this in Space settings too.
 
 
 
 
 
 
17
  ENV WHISPER_MODEL=base
18
 
19
- # Copy files
20
  WORKDIR /app
21
  COPY requirements.txt .
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
24
  COPY app.py .
25
- COPY README.md .
26
 
27
- # Hugging Face Spaces expects the app to listen on port 7860
28
  ENV PORT=7860
29
 
30
- # (Optional) Pre-download models on build to reduce cold-start
31
- #Comment out if build time becomes too long
32
- RUN python -c "import nltk; \
33
- from nltk.sentiment.vader import SentimentIntensityAnalyzer as _; \
34
- import nltk; \
35
- nltk.download('vader_lexicon'); \
36
- whisper.load_model('${WHISPER_MODEL}')"
37
-
38
- # Start FastAPI with uvicorn
39
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # Lightweight Python image
2
  FROM python:3.10-slim
3
 
4
+ # System deps
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  ffmpeg git build-essential \
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
+ # Make writable dirs for caches and NLTK
10
+ RUN mkdir -p /data/nltk_data \
11
+ /data/huggingface/transformers \
12
+ /data/huggingface/datasets \
13
+ /data/tmp && chmod -R 777 /data
14
 
15
+ # Point all caches to /data (writable)
16
+ ENV NLTK_DATA=/data/nltk_data
17
+ ENV HF_HOME=/data/huggingface
18
+ ENV TRANSFORMERS_CACHE=/data/huggingface/transformers
19
+ ENV HF_DATASETS_CACHE=/data/huggingface/datasets
20
+ ENV TMPDIR=/data/tmp
21
+
22
+ # Optional: choose Whisper size via env (ignored now if using SpeechRecognition)
23
  ENV WHISPER_MODEL=base
24
 
 
25
  WORKDIR /app
26
  COPY requirements.txt .
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
  COPY app.py .
30
+ COPY README.md .
31
 
32
+ # Spaces expects port 7860
33
  ENV PORT=7860
34
 
35
+ # Start FastAPI
 
 
 
 
 
 
 
 
36
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]