File size: 1,303 Bytes
1aa90a9
 
 
 
 
 
 
 
 
 
 
 
 
6bba0e5
5cc8a69
 
6bba0e5
1aa90a9
 
859f6af
 
 
 
1aa90a9
 
 
 
 
 
 
06e45f0
1aa90a9
 
 
 
 
 
a4fc0b9
1aa90a9
 
 
 
 
8586027
 
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
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile

FROM python:3.9

# Install system dependencies
RUN apt-get update && apt-get install -y \
    ffmpeg \
    imagemagick \
    fonts-liberation \
    wget \
    && rm -rf /var/lib/apt/lists/*

# Fix ImageMagick policy to allow text rendering
# Use find to locate policy.xml as the path varies by version
RUN find /etc -name "policy.xml" -exec sed -i 's/none/read,write/g' {} +

# Create user for Hugging Face Spaces
RUN useradd -m -u 1000 user

# Create data directory with correct permissions
RUN mkdir -p /data && chown -R user:user /data

USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

# Copy requirements and install dependencies
COPY --chown=user ./requirements.txt requirements.txt
# Force reinstall of dependencies
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy application code
COPY --chown=user . /app

# Hugging Face Spaces Configuration
ENV PORT=8880
ENV DATA_DIR_PATH=/data
ENV DOCKER=true
ENV LOG_LEVEL=info
ENV WHISPER_MODEL=tiny.en

# Start the server (MUST use single worker to maintain queue state!)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8880", "--workers", "1", "--timeout-keep-alive", "3600"]