File size: 1,275 Bytes
0430b13
fd980af
 
0430b13
fd980af
 
0430b13
52e0867
 
 
 
 
5677c26
 
 
fd980af
0430b13
52e0867
 
 
 
 
 
fd980af
0430b13
52e0867
 
fd980af
0430b13
5677c26
 
 
0430b13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ===== Base Image =====
FROM python:3.10-slim

# ===== Working Directory =====
WORKDIR /app

# ===== Environment Variables =====
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    HF_HOME=/tmp/huggingface \
    TRANSFORMERS_CACHE=/tmp/huggingface \
    HF_DATASETS_CACHE=/tmp/huggingface \
    HF_HUB_CACHE=/tmp/huggingface \
    TORCH_HOME=/tmp/huggingface \
    XDG_CACHE_HOME=/tmp/huggingface

# ===== System Dependencies =====
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    ffmpeg \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

# ===== Python Dependencies =====
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# ===== Cache & Permissions =====
RUN rm -rf /.cache /root/.cache /root/.huggingface && \
    mkdir -p /tmp/huggingface && \
    chmod -R 777 /tmp /app

# ===== Copy Project Files =====
COPY . .

# ===== Optional Performance Libraries =====
RUN pip install --no-cache-dir uvloop gunicorn

# ===== Expose App Port =====
EXPOSE 7860

# ===== Healthcheck =====
HEALTHCHECK CMD curl --fail http://localhost:7860/health || exit 1

# ===== Start App =====
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2", "--timeout-keep-alive", "30"]