WebashalarForML commited on
Commit
04e0ce2
·
verified ·
1 Parent(s): c9d7ff6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -44
Dockerfile CHANGED
@@ -1,77 +1,62 @@
1
- # Use an official Python runtime as a parent image
2
- # This base image is Debian 12 "Bookworm"
3
  FROM python:3.9-slim
4
 
5
- # Set environment variables for Python and Numba
6
  ENV PYTHONDONTWRITEBYTECODE=1 \
7
  PYTHONUNBUFFERED=1 \
8
- NUMBA_CACHE_DIR=/tmp/numba_cache
 
9
 
10
- # Set the working directory
11
  WORKDIR /app
12
 
13
- # Install build dependencies and LLVM components from Debian's default repos (Bookworm)
14
  RUN apt-get update && \
15
  apt-get install -y --no-install-recommends \
16
  build-essential \
17
  libedit-dev \
18
  libffi-dev \
19
  python3-dev \
20
- libgl1-mesa-glx \
21
- libsm6 \
22
- libxrender1 \
23
- libglib2.0-0 \
24
  ffmpeg \
25
- libsndfile1 \
26
- libsndfile1-dev \
27
- # Install LLVM 14, which is common in Debian Bookworm
28
- clang-14 \
29
- llvm-14-dev \
30
- llvm-14-runtime \
31
- && rm -rf /var/lib/apt/lists/*
32
 
33
- # Set LLVM_CONFIG for clang-14 (needed by llvmlite)
34
  ENV LLVM_CONFIG=/usr/bin/llvm-config-14
35
 
36
- # --- CRITICAL CHANGE: Ensure correct NumPy version ---
37
- # First, remove any pre-installed numpy that might conflict
38
- RUN pip uninstall -y numpy || true
39
 
40
- # Explicitly install the exact NumPy 1.x version
41
- # This must come BEFORE numba and librosa to ensure they compile/install against it.
42
- RUN pip install --no-cache-dir numpy==1.22.4
43
-
44
- # Install llvmlite, numba, resampy, librosa which depend on numpy
45
  RUN pip install --no-cache-dir \
46
- llvmlite==0.36.0 \
47
- numba==0.53.1 \
48
- resampy==0.3.1 \
49
- librosa==0.9.2
50
 
51
- # Copy the requirements file into the container at /app
52
  COPY requirements.txt /app/
53
-
54
- # Install other Python dependencies from requirements.txt
55
- # IT IS CRUCIAL that requirements.txt does NOT contain any numpy version that would conflict.
56
- # If it does, you MUST remove or modify it.
57
  RUN pip install --no-cache-dir -r requirements.txt
58
 
59
- # Copy the rest of the application
60
  COPY . /app/
61
 
62
- # Create necessary directories
63
- RUN mkdir -p /app/cache /app/uploads /app/results /app/checkpoints /app/temp \
64
- && chmod -R 777 /app/cache /app/uploads /app/results /app/checkpoints /app/temp
65
 
66
- # Ensure full permissions for app directory
67
  RUN chmod -R 777 /app
68
 
69
- # Expose the app port
70
  EXPOSE 7860
71
 
72
- # Set Flask environment variables
73
  ENV FLASK_APP=app.py \
74
  FLASK_ENV=production
75
 
76
- # Start the application with Gunicorn
77
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
 
1
+ # Use an official Python runtime as a parent image (Debian 12 Bookworm)
 
2
  FROM python:3.9-slim
3
 
4
+ # Disable Python bytecode and buffer stdout/stderr
5
  ENV PYTHONDONTWRITEBYTECODE=1 \
6
  PYTHONUNBUFFERED=1 \
7
+ # Ensure NumPy <2 so all C extensions load correctly
8
+ NUMPY_EXPLICIT_VERSION=1.23.5
9
 
10
+ # Working directory
11
  WORKDIR /app
12
 
13
+ # Install build dependencies, audio/video libs, and LLVM 14 for llvmlite
14
  RUN apt-get update && \
15
  apt-get install -y --no-install-recommends \
16
  build-essential \
17
  libedit-dev \
18
  libffi-dev \
19
  python3-dev \
20
+ libgl1-mesa-glx libsm6 libxrender1 libglib2.0-0 \
 
 
 
21
  ffmpeg \
22
+ libsndfile1 libsndfile1-dev \
23
+ clang-14 llvm-14-dev llvm-14-runtime \
24
+ && rm -rf /var/lib/apt/lists/*
 
 
 
 
25
 
26
+ # Point llvmlite at the correct llvm-config
27
  ENV LLVM_CONFIG=/usr/bin/llvm-config-14
28
 
29
+ # Remove any preinstalled NumPy, then install a NumPy 1.x release
30
+ RUN pip uninstall -y numpy || true && \
31
+ pip install --no-cache-dir numpy==${NUMPY_EXPLICIT_VERSION}
32
 
33
+ # Install the trio that need to compile against NumPy 1.x
 
 
 
 
34
  RUN pip install --no-cache-dir \
35
+ llvmlite==0.38.0 \
36
+ numba==0.55.2 \
37
+ resampy==0.3.1 \
38
+ librosa==0.9.2
39
 
40
+ # Copy your application requirements (must NOT re‑pin NumPy)
41
  COPY requirements.txt /app/
 
 
 
 
42
  RUN pip install --no-cache-dir -r requirements.txt
43
 
44
+ # Copy application code
45
  COPY . /app/
46
 
47
+ # Create and permissively chmod required directories
48
+ RUN mkdir -p cache uploads results checkpoints temp && \
49
+ chmod -R 777 cache uploads results checkpoints temp
50
 
51
+ # Ensure the entire app directory is writable
52
  RUN chmod -R 777 /app
53
 
54
+ # Expose the inference port
55
  EXPOSE 7860
56
 
57
+ # Environment variables for Flask
58
  ENV FLASK_APP=app.py \
59
  FLASK_ENV=production
60
 
61
+ # Launch with Gunicorn (defaults: 1 worker, sync, 30s timeout)
62
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]