Spaces:
Build error
Build error
| FROM python:3.11-slim AS frontend-builder | |
| # Install Node.js | |
| RUN apt-get update && apt-get install -y curl && \ | |
| curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ | |
| apt-get install -y nodejs && \ | |
| rm -rf /var/lib/apt/lists/* | |
| WORKDIR /frontend | |
| # Copy frontend files | |
| COPY frontend/package.json frontend/pnpm-lock.yaml* frontend/package-lock.json* ./ | |
| # Install dependencies | |
| RUN npm install | |
| # Copy source | |
| COPY frontend/ . | |
| # Use the space config for export | |
| COPY frontend/next.config.space.js ./next.config.js | |
| # Build | |
| RUN npm run build | |
| # ============================================ | |
| # Final Runtime Stage | |
| # ============================================ | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Set env vars | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PORT=7860 \ | |
| DATABASE_URL="sqlite+aiosqlite:///./storage/audioforge.db" \ | |
| REDIS_URL="redis://localhost:6379/0" \ | |
| MUSICGEN_DEVICE="cuda" \ | |
| BARK_DEVICE="cuda" | |
| # Install system dependencies | |
| # git is required for installing dependencies from git (audiocraft) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| git \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| redis-server \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy backend dependency file | |
| COPY backend/pyproject.toml . | |
| # Install Python dependencies (including ML) | |
| RUN pip install --upgrade pip && \ | |
| pip install uv && \ | |
| uv pip install --system -e ".[ml]" | |
| # Setup storage | |
| RUN mkdir -p /app/storage/audio/music \ | |
| /app/storage/audio/vocals \ | |
| /app/storage/audio/mixed \ | |
| /app/storage/audio/mastered \ | |
| /app/storage/models | |
| # Copy backend code | |
| COPY backend/app ./app | |
| COPY backend/app_hf.py ./app_hf.py | |
| # Copy frontend build to static | |
| COPY --from=frontend-builder /frontend/out /app/static | |
| # Copy entrypoint | |
| COPY entrypoint.sh /app/entrypoint.sh | |
| RUN chmod +x /app/entrypoint.sh | |
| # Create user | |
| RUN useradd -m -u 1000 user | |
| RUN chown -R user:user /app | |
| USER user | |
| CMD ["/app/entrypoint.sh"] | |