File size: 1,766 Bytes
2272891
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Hugging Face Docker Spaces base image
FROM python:3.10-slim

# -------------------------------------------------
# System dependencies
# -------------------------------------------------
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    wget \
    && rm -rf /var/lib/apt/lists/*

# -------------------------------------------------
# Environment variables
# -------------------------------------------------
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV TRANSFORMERS_CACHE=/data/.cache/huggingface
ENV HF_HOME=/data/.cache/huggingface
ENV NLTK_DATA=/data/nltk_data

# -------------------------------------------------
# Create working directory
# -------------------------------------------------
WORKDIR /app

# -------------------------------------------------
# Install Python dependencies
# -------------------------------------------------
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# -------------------------------------------------
# Pre-download NLTK resources (avoid runtime downloads)
# -------------------------------------------------
RUN python - <<EOF
import nltk
nltk.download("punkt", download_dir="/data/nltk_data")
nltk.download("punkt_tab", download_dir="/data/nltk_data")
EOF

# -------------------------------------------------
# Copy application code
# -------------------------------------------------
COPY app.py .
COPY static ./static

# -------------------------------------------------
# Expose HF-required port
# -------------------------------------------------
EXPOSE 7860

# -------------------------------------------------
# Start FastAPI
# -------------------------------------------------
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]