garyuzair commited on
Commit
14efaa5
·
verified ·
1 Parent(s): 01eb664

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -35
Dockerfile CHANGED
@@ -1,48 +1,51 @@
1
- # Base image (as requested - WARNING: Lacks CUDA drivers for GPU acceleration)
2
  FROM python:3.9-slim
3
 
4
- # Set environment variables
5
- ENV DEBIAN_FRONTEND=noninteractive
6
- ENV PYTHONUNBUFFERED=1
7
- ENV SHELL=/bin/bash
8
-
9
- # Set working directory
10
  WORKDIR /app
11
 
12
- # Install system dependencies from packages.txt (via apt-get)
13
- # Includes: ffmpeg (needed by ffmpeg-python), git (needed by parler-tts install)
14
- # Includes: build-essential & python3-dev (needed for compiling some pip packages)
15
- # Includes: curl (needed for HEALTHCHECK)
 
 
16
  RUN apt-get update && apt-get install -y --no-install-recommends \
17
  build-essential \
18
  curl \
19
- software-properties-common \
20
  git \
 
21
  ffmpeg \
22
  python3-dev \
23
- && \
24
- # Clean up apt cache to reduce image size
25
- rm -rf /var/lib/apt/lists/*
26
 
27
- # Copy requirements file first to leverage Docker cache
28
  COPY requirements.txt ./
29
 
30
- # Install Python dependencies from the requirements file
31
- # Note: On this non-CUDA base, pip will likely install CPU-only torch/diffusers.
32
- RUN pip3 install --no-cache-dir -r requirements.txt
33
-
34
- # Copy the application code from your local 'src' directory to the container's '/app/src' directory
35
- COPY src/ ./src/
36
-
37
- # Expose the default Streamlit port
38
- EXPOSE 8501
39
-
40
- # Health check for Hugging Face Spaces compatibility
41
- # Checks if the Streamlit core endpoint is reachable
42
- HEALTHCHECK --interval=15s --timeout=5s --start-period=30s --retries=3 \
43
- CMD curl --fail http://localhost:8501/_stcore/health || exit 1
44
-
45
- # Command to run the Streamlit application when the container starts
46
- # Points to the script inside the 'src' directory
47
- # Includes flags to make Streamlit accessible externally on the specified port
48
- CMD ["streamlit", "run", "src/app_hf_space_optimized.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
+ # Set the working directory in the container
 
 
 
 
 
5
  WORKDIR /app
6
 
7
+ # Install system dependencies:
8
+ # - build-essential: For compiling some Python packages if needed
9
+ # - curl, git, software-properties-common: General utilities, git for some pip installs
10
+ # - ffmpeg: For video processing
11
+ # - python3-dev: For C extensions if any Python package needs to build them
12
+ # - libsndfile1: For soundfile to work correctly
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  build-essential \
15
  curl \
 
16
  git \
17
+ software-properties-common \
18
  ffmpeg \
19
  python3-dev \
20
+ libsndfile1 \
21
+ && rm -rf /var/lib/apt/lists/*
 
22
 
23
+ # Copy the requirements file into the container at /app
24
  COPY requirements.txt ./
25
 
26
+ # Install any needed packages specified in requirements.txt
27
+ # --no-cache-dir: Reduces image size by not storing the pip cache
28
+ # It's good practice to upgrade pip first
29
+ RUN pip install --no-cache-dir --upgrade pip
30
+ RUN pip install --no-cache-dir -r requirements.txt
31
+
32
+ # Copy the rest of the application code into the container at /app
33
+ COPY . .
34
+
35
+ # Make port 7860 available to the world outside this container (Streamlit default)
36
+ # Hugging Face Spaces will handle the actual port mapping.
37
+ EXPOSE 7860
38
+
39
+ # Define environment variables for Hugging Face Hub caching (optional but good practice)
40
+ # These will be overridden by HF Spaces secrets/vars if set there, but good defaults.
41
+ ENV HUGGINGFACE_HUB_CACHE=/app/.cache/huggingface/hub
42
+ ENV HF_HOME=/app/.cache/huggingface
43
+ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/hub
44
+ ENV DIFFUSERS_CACHE=/app/.cache/huggingface/hub
45
+ # Create the cache directory and set permissions (if needed, usually pip creates it)
46
+ # RUN mkdir -p /app/.cache/huggingface/hub && chmod -R 777 /app/.cache
47
+
48
+ # Command to run the Streamlit application
49
+ # The --server.port and --server.address are important for HF Spaces.
50
+ # --server.fileWatcherType none can prevent issues in some environments.
51
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.fileWatcherType=none"]