Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +24 -24
Dockerfile
CHANGED
@@ -1,16 +1,21 @@
|
|
1 |
# Use an official Python runtime as a parent image (Debian 12 Bookworm)
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
-
# Disable Python bytecode
|
5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
6 |
PYTHONUNBUFFERED=1 \
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
10 |
-
# Working directory
|
11 |
WORKDIR /app
|
12 |
|
13 |
-
#
|
|
|
|
|
|
|
|
|
14 |
RUN apt-get update && \
|
15 |
apt-get install -y --no-install-recommends \
|
16 |
build-essential \
|
@@ -23,30 +28,25 @@ RUN apt-get update && \
|
|
23 |
clang-14 llvm-14-dev llvm-14-runtime \
|
24 |
&& rm -rf /var/lib/apt/lists/*
|
25 |
|
26 |
-
#
|
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 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
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
|
48 |
-
RUN mkdir -p
|
49 |
-
chmod -R 777
|
50 |
|
51 |
# Ensure the entire app directory is writable
|
52 |
RUN chmod -R 777 /app
|
@@ -54,9 +54,9 @@ RUN chmod -R 777 /app
|
|
54 |
# Expose the inference port
|
55 |
EXPOSE 7860
|
56 |
|
57 |
-
#
|
58 |
ENV FLASK_APP=app.py \
|
59 |
FLASK_ENV=production
|
60 |
|
61 |
-
# Launch with Gunicorn (
|
62 |
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, buffer stdout/stderr, pin NumPy <2, and redirect caches
|
5 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
6 |
PYTHONUNBUFFERED=1 \
|
7 |
+
NUMPY_EXPLICIT_VERSION=1.23.5 \
|
8 |
+
XDG_CACHE_HOME=/app/cache \
|
9 |
+
TORCH_HOME=/app/cache/torch \
|
10 |
+
LLVM_CONFIG=/usr/bin/llvm-config-14
|
11 |
|
|
|
12 |
WORKDIR /app
|
13 |
|
14 |
+
# Create cache dirs before anything else
|
15 |
+
RUN mkdir -p /app/cache/torch/hub \
|
16 |
+
&& chmod -R 777 /app/cache
|
17 |
+
|
18 |
+
# Install build dependencies, audio/video libs, and LLVM 14
|
19 |
RUN apt-get update && \
|
20 |
apt-get install -y --no-install-recommends \
|
21 |
build-essential \
|
|
|
28 |
clang-14 llvm-14-dev llvm-14-runtime \
|
29 |
&& rm -rf /var/lib/apt/lists/*
|
30 |
|
31 |
+
# Pin NumPy to 1.x, then install libs that must compile against it
|
|
|
|
|
|
|
32 |
RUN pip uninstall -y numpy || true && \
|
33 |
+
pip install --no-cache-dir numpy==${NUMPY_EXPLICIT_VERSION} && \
|
34 |
+
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 |
+
# Install your other Python dependencies
|
|
|
|
|
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 chmod the uploads/results/checkpoints/temp dirs
|
48 |
+
RUN mkdir -p uploads results checkpoints temp \
|
49 |
+
&& chmod -R 777 uploads results checkpoints temp
|
50 |
|
51 |
# Ensure the entire app directory is writable
|
52 |
RUN chmod -R 777 /app
|
|
|
54 |
# Expose the inference port
|
55 |
EXPOSE 7860
|
56 |
|
57 |
+
# Set Flask env
|
58 |
ENV FLASK_APP=app.py \
|
59 |
FLASK_ENV=production
|
60 |
|
61 |
+
# Launch with Gunicorn (1 worker, sync, 30s timeout)
|
62 |
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]
|