Spaces:
Running
Running
File size: 1,922 Bytes
ba1fd72 7786e96 e65a8eb 7f8855a 9e4a797 890829d 7f8855a ba1fd72 e65a8eb 7f8855a ba1fd72 b039445 ba1fd72 b039445 ba1fd72 04e0ce2 7b8f950 7f8855a 04e0ce2 7f8855a c9d7ff6 3b64741 35e2a0f 04e0ce2 b5f1353 7f8855a ba1fd72 c7b30a2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # Use an official Python runtime as a parent image (Debian Bookworm/Trixie)
FROM python:3.9-slim
# Disable Python bytecode, buffer stdout/stderr, pin NumPy <2, and redirect caches
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
NUMPY_EXPLICIT_VERSION=1.23.5 \
XDG_CACHE_HOME=/app/cache \
TORCH_HOME=/app/cache/torch \
LLVM_CONFIG=/usr/bin/llvm-config
WORKDIR /app
# Create cache dirs before anything else
RUN mkdir -p /app/cache/torch/hub \
&& chmod -R 777 /app/cache
# Install system dependencies (FIXED)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libedit-dev \
libffi-dev \
python3-dev \
libgl1 \
libsm6 \
libxrender1 \
libglib2.0-0 \
ffmpeg \
libsndfile1 \
libsndfile1-dev \
clang \
llvm \
&& rm -rf /var/lib/apt/lists/*
# Pin NumPy to 1.x, then install libs that must compile against it
RUN pip uninstall -y numpy || true && \
pip install --no-cache-dir numpy==${NUMPY_EXPLICIT_VERSION} && \
pip install --no-cache-dir \
llvmlite==0.38.0 \
numba==0.55.2 \
resampy==0.3.1 \
librosa==0.9.2
# Install your other Python dependencies
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . /app/
# Create and chmod the uploads/results/checkpoints/temp dirs
RUN mkdir -p uploads results checkpoints temp \
&& chmod -R 777 uploads results
EXPOSE 7860
# Set Flask env
ENV FLASK_APP=app.py \
FLASK_ENV=production
# Launch with Gunicorn:
# - gthread: threaded worker class
# - threads=2: two threads per worker
# - timeout=600: 10-minute timeout to cover long inferences
CMD ["gunicorn", \
"--worker-class", "gthread", \
"--threads", "2", \
"--timeout", "600", \
"--bind", "0.0.0.0:7860", \
"app:app"]
|