File size: 1,766 Bytes
0a1c5fe
 
a2f1499
0a1c5fe
 
 
 
 
 
a2f1499
 
 
 
1519b2b
0a1c5fe
 
a2f1499
0a1c5fe
 
5b73e2d
 
0a1c5fe
 
 
5b73e2d
0a46798
5b73e2d
 
739e423
0a1c5fe
 
a2f1499
5b73e2d
 
0a1c5fe
 
 
a2f1499
 
0a1c5fe
 
 
 
5224e6a
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
FROM python:3.10-slim

# ── System deps ────────────────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y \
    ffmpeg git curl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# ── Upgrade pip + fix typing-extensions before torch ──────────────────────────
RUN pip install --no-cache-dir --upgrade pip "typing-extensions>=4.10.0"

# ── PyTorch CPU (needed by faster-whisper / transformers) ─────────────────────
RUN pip install --no-cache-dir "torch>=2.6.0" torchaudio \
    --index-url https://download.pytorch.org/whl/cpu

# ── Core app deps ──────────────────────────────────────────────────────────────
RUN pip install --no-cache-dir \
    fastapi uvicorn \
    requests httpx \
    python-multipart aiofiles \
    groq \
    deep-translator transformers tokenizers \
    huggingface_hub sentencepiece sacremoses \
    soundfile numpy \
    librosa ffmpeg-python faster-whisper \
    cloudinary \
    cleanvoice-sdk

COPY . .

# ── Fix cache dir permissions before switching user ────────────────────────────
RUN mkdir -p /app/.cache/huggingface && chown -R 1000:1000 /app

RUN useradd -m -u 1000 user
USER user

ENV HF_HOME=/app/.cache/huggingface
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
ENV HOME=/home/user

EXPOSE 7860

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]