Spaces:
Running
Running
Update Dockerfile
Browse files- 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 |
-
#
|
6 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
7 |
PYTHONUNBUFFERED=1 \
|
8 |
-
|
|
|
9 |
|
10 |
-
#
|
11 |
WORKDIR /app
|
12 |
|
13 |
-
# Install build dependencies and LLVM
|
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 |
-
|
27 |
-
|
28 |
-
clang-14 \
|
29 |
-
llvm-14-dev \
|
30 |
-
llvm-14-runtime \
|
31 |
-
&& rm -rf /var/lib/apt/lists/*
|
32 |
|
33 |
-
#
|
34 |
ENV LLVM_CONFIG=/usr/bin/llvm-config-14
|
35 |
|
36 |
-
#
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
#
|
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 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
# Copy
|
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
|
60 |
COPY . /app/
|
61 |
|
62 |
-
# Create
|
63 |
-
RUN mkdir -p
|
64 |
-
|
65 |
|
66 |
-
# Ensure
|
67 |
RUN chmod -R 777 /app
|
68 |
|
69 |
-
# Expose the
|
70 |
EXPOSE 7860
|
71 |
|
72 |
-
#
|
73 |
ENV FLASK_APP=app.py \
|
74 |
FLASK_ENV=production
|
75 |
|
76 |
-
#
|
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"]
|