File size: 963 Bytes
ce84690
 
 
 
 
 
 
 
 
 
18c700b
ce84690
 
 
 
4699653
 
 
18c700b
 
ce84690
 
 
4699653
 
 
18c700b
 
ce84690
 
18c700b
ce84690
 
18c700b
4699653
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
# 1️⃣ Base image
FROM python:3.11-slim

# Prevent Python from writing pyc files & buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# 2️⃣ Set working directory
WORKDIR /app

# 3️⃣ Install OS dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
 && rm -rf /var/lib/apt/lists/*

# 4️⃣ Set Hugging Face cache to /tmp (auto-cleaned by system)
ENV HF_HOME=/tmp/.huggingface
RUN mkdir -p /tmp/.huggingface

# 5️⃣ Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 6️⃣ REMOVED: Pre-download was causing cache buildup
# Model will download at runtime to /tmp instead
# This prevents Docker layer accumulation

# 7️⃣ Copy the entire project
COPY . .

# 8️⃣ Expose HF Spaces default port
EXPOSE 7860

# 9️⃣ Run the app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]