Spaces:
Sleeping
Sleeping
File size: 1,640 Bytes
2f93c82 1aa655b 91427c6 2698bfc ec492d9 1aa655b ec492d9 1aa655b 2698bfc ec492d9 ae318c6 91427c6 ec492d9 91427c6 312dec1 e23ba61 ec492d9 2f93c82 1aa655b f8353c2 ec492d9 1aa655b ec492d9 1aa655b 84b5286 1aa655b | 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 | FROM python:3.10-slim-bookworm AS builder
# Install system dependencies for compiling audio tools and Python packages
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies.
# Ensure we use a CPU-only version of PyTorch to avoid CUDA bloat.
# If your requirements.txt already pulls torch without CUDA, you can keep the simple install.
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt \
--extra-index-url https://download.pytorch.org/whl/cpu
# Final stage
FROM python:3.10-slim-bookworm
# Install runtime system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code
COPY app.py .
# Create non-root user for security
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
# Environment variables with defaults
ENV MODEL_SIZE=small \
MAX_FILE_SIZE_MB=200 \
LOG_LEVEL=INFO \
PORT=7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |