Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +31 -29
Dockerfile
CHANGED
|
@@ -1,35 +1,37 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
RUN useradd -m -u 1000 user
|
| 10 |
-
|
| 11 |
-
# Switch to the "user" user
|
| 12 |
USER user
|
| 13 |
-
|
| 14 |
-
# Set home to the user's home directory
|
| 15 |
ENV HOME=/home/user \
|
| 16 |
PATH=/home/user/.local/bin:$PATH
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 22 |
-
COPY --chown=user . $HOME/app
|
| 23 |
-
|
| 24 |
-
### Set up app-specific content
|
| 25 |
-
COPY requirements.txt requirements.txt
|
| 26 |
-
RUN pip3 install -r requirements.txt
|
| 27 |
-
|
| 28 |
-
COPY . .
|
| 29 |
-
|
| 30 |
-
### Update permissions for the app
|
| 31 |
-
USER root
|
| 32 |
-
RUN chmod 777 ~/app/*
|
| 33 |
-
USER user
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
| 1 |
+
# Use Python 3.10 as base
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# 1. Install System Dependencies
|
| 5 |
+
# libgl1-mesa-glx: Required for OpenCV
|
| 6 |
+
# libasound2-dev & libssl-dev: Required for Azure Speech SDK
|
| 7 |
+
# ffmpeg: Helper for audio processing
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
libgl1-mesa-glx \
|
| 10 |
+
libglib2.0-0 \
|
| 11 |
+
libasound2 \
|
| 12 |
+
libasound2-plugins \
|
| 13 |
+
libssl-dev \
|
| 14 |
+
ffmpeg \
|
| 15 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 16 |
+
|
| 17 |
+
# 2. Setup Work Directory
|
| 18 |
+
WORKDIR /app
|
| 19 |
+
|
| 20 |
+
# 3. Install Python Dependencies
|
| 21 |
+
COPY requirements.txt .
|
| 22 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 23 |
+
|
| 24 |
+
# 4. Copy Server Code
|
| 25 |
+
COPY app.py .
|
| 26 |
+
|
| 27 |
+
# 5. Security: Create non-root user (Mandatory for HF Spaces)
|
| 28 |
RUN useradd -m -u 1000 user
|
|
|
|
|
|
|
| 29 |
USER user
|
|
|
|
|
|
|
| 30 |
ENV HOME=/home/user \
|
| 31 |
PATH=/home/user/.local/bin:$PATH
|
| 32 |
|
| 33 |
+
# 6. Expose the specific HF port
|
| 34 |
+
EXPOSE 7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
# 7. Start Command using Gunicorn + Eventlet
|
| 37 |
+
CMD ["gunicorn", "--worker-class", "eventlet", "-w", "1", "--bind", "0.0.0.0:7860", "app:app"]
|