kicks-api / Dockerfile
thepaul's picture
Add BigVGAN vocoder with CUDA support
ba9111a
Raw History Blame Contribute Delete
1.22 kB
FROM python:3.11-slim
# Prevent Python from writing .pyc files and buffer stdout
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DEBIAN_FRONTEND=noninteractive
# Install system deps: libsndfile for soundfile, build-essential for torch
RUN apt-get update && apt-get install -y --no-install-recommends \
libsndfile1 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user (UID 1000 required by HF Spaces Dev Mode)
RUN useradd -m -u 1000 user
# Install uv for faster pip installs
RUN pip install --no-cache-dir uv
# Install PyTorch with CUDA support (GPU Space)
RUN uv pip install --system --no-cache-dir \
torch \
torchaudio \
&& uv cache clean
# Install app dependencies
WORKDIR /app
COPY --chown=user ./requirements.txt .
RUN uv pip install --system --no-cache-dir -r requirements.txt \
&& uv cache clean
# Copy application code and model files
COPY --chown=user . .
# Redirect HF/torch caches to /tmp (only writable directory on Spaces)
ENV HF_HOME=/tmp/hf_cache \
TORCH_HOME=/tmp/hf_cache/torch
# Switch to non-root user
USER user
# Expose the expected HF Spaces port
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]