File size: 1,695 Bytes
9223d83
 
 
 
 
 
a13d171
 
a251e69
a13d171
9223d83
b79d0eb
a13d171
 
b72fff2
a13d171
a251e69
a13d171
 
a251e69
 
 
 
 
 
 
 
9223d83
b72fff2
 
 
a13d171
 
b72fff2
a13d171
a251e69
 
 
 
 
a13d171
b72fff2
d79d44c
a13d171
b72fff2
88960e3
 
 
 
 
b72fff2
a13d171
88960e3
b72fff2
a13d171
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
49
50
51
52
53
54
55
# ---------------------------------------------------------------
# CRITICAL CHANGE: Use the FULL Python image (not slim).
# The 'slim' image lacks the C-level SSL libraries required
# by the Azure Speech SDK to initialize its platform.
# ---------------------------------------------------------------
FROM python:3.10

# 1. Install System Dependencies
# + curl so we can pull libssl1.1 manually
RUN apt-get update && apt-get install -y \
    build-essential \
    libgl1 \
    libasound2 \
    libssl-dev \
    ca-certificates \
    ffmpeg \
    curl \
    && rm -rf /var/lib/apt/lists/*

# 1b. Install libssl1.1 (Azure Speech SDK still wants this on Debian-based images)
# Source: Debian pool; works for bookworm too.
RUN export arch=$(dpkg --print-architecture) \
 && curl -sSLo /tmp/libssl1.1.deb \
      "https://deb.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_${arch}.deb" \
 && dpkg -i /tmp/libssl1.1.deb \
 && rm /tmp/libssl1.1.deb

# 2. Force update of security certificates
RUN update-ca-certificates

# 3. Setup Work Directory
WORKDIR /app

# 4. Install Python Dependencies
COPY requirements.txt .

# Make sure we’re on a recent Speech SDK
RUN pip install --no-cache-dir -r requirements.txt \
    && pip install --no-cache-dir --upgrade \
       "azure-cognitiveservices-speech>=1.46.0" "azure-core>=1.36.0"

# 5. Copy Server Code
COPY . .

# 6. Security: Create non-root user (Mandatory for HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# 7. Expose the specific HF port
EXPOSE 7860

# 8. Start Command
CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "--bind", "0.0.0.0:7860", "app:app"]