File size: 907 Bytes
801b1af
 
 
 
 
c55464d
801b1af
 
 
 
 
c55464d
 
 
 
40a853b
 
 
 
801b1af
88b3c9e
c55464d
 
40a853b
ac34b3e
801b1af
88b3c9e
 
 
40a853b
ac34b3e
 
801b1af
 
 
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
FROM python:3.11-slim

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# 1. Install system dependencies (root)
RUN apt-get update && apt-get install -y \
    ffmpeg \
    git \
    && rm -rf /var/lib/apt/lists/*

# 2. Install Python dependencies globally (root).
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 3. Create the unprivileged user and writable cache dir
RUN useradd -m -u 1000 user && \
    mkdir -p /home/user/.cache/huggingface && \
    chown -R user:user /home/user/.cache

# 4. Switch context to the unprivileged user
USER user
ENV HOME=/home/user
ENV HF_HOME=/home/user/.cache/huggingface
WORKDIR $HOME/app

# 5. Pre-cache the 'base' model to avoid runtime downloads/timeouts
RUN python -c "from faster_whisper import download_model; download_model('base')"

# 6. Copy the application code
COPY --chown=user . .

EXPOSE 7860

CMD ["python", "backend.py"]