rairo commited on
Commit
7d19c12
·
verified ·
1 Parent(s): 79cf860

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -23
Dockerfile CHANGED
@@ -1,31 +1,57 @@
 
 
 
1
  FROM python:3.10
2
 
3
- ### Set up user with permissions
4
- # Set up a new user named "user" with user ID 1000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  RUN useradd -m -u 1000 user
6
-
7
- # Switch to the "user" user
8
  USER user
9
-
10
- # Set home to the user's home directory
11
  ENV HOME=/home/user \
12
  PATH=/home/user/.local/bin:$PATH
13
 
14
- # Set the working directory to the user's home directory
15
- WORKDIR $HOME/app
16
-
17
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
18
- COPY --chown=user . $HOME/app
19
-
20
- ### Set up app-specific content
21
- COPY requirements.txt requirements.txt
22
- RUN pip3 install -r requirements.txt
23
-
24
- COPY . .
25
-
26
- ### Update permissions for the app
27
- USER root
28
- RUN chmod 777 ~/app/*
29
- USER user
30
 
31
- CMD ["python", "main.py"]
 
 
1
+ # ---------------------------------------------------------------
2
+ # Use FULL Python image (not slim) — required by Azure Speech SDK
3
+ # ---------------------------------------------------------------
4
  FROM python:3.10
5
 
6
+ # 1. Install System Dependencies
7
+ # - ffmpeg: audio sanitize
8
+ # - libssl-dev + libssl1.1: Azure Speech SDK compatibility
9
+ # - libgl1/libasound2: common media deps (safe to keep)
10
+ # - curl: pull libssl1.1 .deb
11
+ RUN apt-get update && apt-get install -y \
12
+ build-essential \
13
+ libgl1 \
14
+ libasound2 \
15
+ libssl-dev \
16
+ ca-certificates \
17
+ ffmpeg \
18
+ curl \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # 1b. Install libssl1.1 (Azure Speech SDK still wants this)
22
+ RUN export arch=$(dpkg --print-architecture) \
23
+ && curl -sSLo /tmp/libssl1.1.deb \
24
+ "https://deb.debian.org/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_${arch}.deb" \
25
+ && dpkg -i /tmp/libssl1.1.deb \
26
+ && rm /tmp/libssl1.1.deb
27
+
28
+ # 2. Update security certificates
29
+ RUN update-ca-certificates
30
+
31
+ # 3. Setup Work Directory
32
+ WORKDIR /app
33
+
34
+ # 4. Install Python Dependencies
35
+ COPY requirements.txt .
36
+
37
+ # Ensure Speech SDK is recent + compatible
38
+ RUN pip install --no-cache-dir -r requirements.txt \
39
+ && pip install --no-cache-dir --upgrade \
40
+ "azure-cognitiveservices-speech>=1.46.0" "azure-core>=1.36.0"
41
+
42
+ # 5. Copy Server Code
43
+ # New app uses main.py + language packs like korean.py, english.py, etc.
44
+ COPY main.py .
45
+ COPY *.py ./
46
+
47
+ # 6. Security: Create non-root user (Mandatory for HF Spaces)
48
  RUN useradd -m -u 1000 user
 
 
49
  USER user
 
 
50
  ENV HOME=/home/user \
51
  PATH=/home/user/.local/bin:$PATH
52
 
53
+ # 7. Expose HF port
54
+ EXPOSE 7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ # 8. Start Command (Flask-SocketIO needs eventlet worker)
57
+ CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "--bind", "0.0.0.0:7860", "main:app"]