Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +13 -11
Dockerfile
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
# Set environment variables
|
| 4 |
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
DEBIAN_FRONTEND=noninteractive \
|
| 6 |
-
TF_ENABLE_ONEDNN_OPTS=0
|
|
|
|
| 7 |
|
| 8 |
-
# Install system dependencies
|
| 9 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
ffmpeg \
|
| 11 |
libsm6 \
|
|
@@ -15,26 +17,26 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 15 |
&& apt-get clean \
|
| 16 |
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
-
#
|
| 19 |
WORKDIR /app
|
| 20 |
|
| 21 |
-
# Create user for Hugging Face
|
| 22 |
-
RUN useradd -m -u 1000 user
|
| 23 |
USER user
|
| 24 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 25 |
|
| 26 |
-
# Copy and install Python
|
| 27 |
COPY --chown=user:user requirements.txt /app/
|
| 28 |
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 29 |
|
| 30 |
-
# Copy application code
|
| 31 |
COPY --chown=user:user . /app/
|
| 32 |
|
| 33 |
-
# Create necessary directories
|
| 34 |
RUN mkdir -p /app/captured_images /app/temp_audio
|
| 35 |
|
| 36 |
-
# Expose Hugging Face
|
| 37 |
EXPOSE 7860
|
| 38 |
|
| 39 |
-
#
|
| 40 |
CMD ["python", "app.py"]
|
|
|
|
| 1 |
+
# Use a stable Python 3.11 base image
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# Set environment variables to reduce warnings and improve compatibility
|
| 5 |
ENV PYTHONUNBUFFERED=1 \
|
| 6 |
DEBIAN_FRONTEND=noninteractive \
|
| 7 |
+
TF_ENABLE_ONEDNN_OPTS=0 \
|
| 8 |
+
TF_CPP_MIN_LOG_LEVEL=2
|
| 9 |
|
| 10 |
+
# Install essential system dependencies, including FFmpeg
|
| 11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
ffmpeg \
|
| 13 |
libsm6 \
|
|
|
|
| 17 |
&& apt-get clean \
|
| 18 |
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
|
| 20 |
+
# Set the working directory
|
| 21 |
WORKDIR /app
|
| 22 |
|
| 23 |
+
# Create a non-root user for security (Hugging Face standard)
|
| 24 |
+
RUN useradd -m -u 1000 user
|
| 25 |
USER user
|
| 26 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 27 |
|
| 28 |
+
# Copy and install Python requirements first to leverage Docker cache
|
| 29 |
COPY --chown=user:user requirements.txt /app/
|
| 30 |
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 31 |
|
| 32 |
+
# Copy the rest of the application code
|
| 33 |
COPY --chown=user:user . /app/
|
| 34 |
|
| 35 |
+
# Create necessary directories for the app to function
|
| 36 |
RUN mkdir -p /app/captured_images /app/temp_audio
|
| 37 |
|
| 38 |
+
# Expose the port required by Hugging Face Spaces
|
| 39 |
EXPOSE 7860
|
| 40 |
|
| 41 |
+
# Command to run the Flask application
|
| 42 |
CMD ["python", "app.py"]
|