generated from Labyricorn/labyricorn-project-template
CI / frontend-quality (push) Canceled after 0s
- All 'voicebox'/'Voicebox'/'VOICEBOX' strings replaced with 'talkbox'/'TalkBox'/'TALKBOX' - Port changed from 17493 to 17494 (avoids conflict with upstream VoiceBox) - MCP tool namespace: voicebox.* -> talkbox.* - App bundle ID: sh.voicebox.app -> com.talkbox.app - Binary names: voicebox-server -> talkbox-server, voicebox-mcp -> talkbox-mcp - Docker user/group: voicebox -> talkbox - Database: voicebox.db -> talkbox.db - Env vars: VOICEBOX_* -> TALKBOX_* - Asset files renamed: voicebox-logo.* -> talkbox-logo.*, etc. - External binaries in tauri.conf.json updated to talkbox-server/talkbox-mcp
114 lines
4.0 KiB
Docker
114 lines
4.0 KiB
Docker
# ============================================================
|
|
# TalkBox — Local TTS Server with Web UI
|
|
# 3-stage build: Frontend → Python deps → Runtime
|
|
#
|
|
# Build variants:
|
|
# CPU (default): docker compose up --build
|
|
# ROCm (AMD GPU): docker compose -f docker-compose.yml -f docker-compose.rocm.yml up --build
|
|
# ============================================================
|
|
|
|
# Top-level ARG so it is visible to all stages.
|
|
ARG PYTORCH_VARIANT=cpu
|
|
|
|
# === Stage 1: Build frontend ===
|
|
FROM oven/bun:1 AS frontend
|
|
|
|
WORKDIR /build
|
|
|
|
# Copy workspace config and frontend source
|
|
COPY package.json bun.lock CHANGELOG.md ./
|
|
COPY app/ ./app/
|
|
COPY web/ ./web/
|
|
|
|
# Normalize line endings first (a Windows CRLF checkout would otherwise
|
|
# defeat the `-z 's/,\n ]/…/'` match below, since it's LF-anchored), then
|
|
# strip workspaces not needed for web build, and fix trailing comma
|
|
RUN sed -i 's/\r$//' package.json && \
|
|
sed -i '/"tauri"/d; /"landing"/d' package.json && \
|
|
sed -i -z 's/,\n ]/\n ]/' package.json
|
|
RUN bun install --no-save
|
|
# Build frontend (skip tsc — upstream has pre-existing type errors)
|
|
RUN cd web && bunx --bun vite build
|
|
|
|
|
|
# === Stage 2: Build Python dependencies ===
|
|
FROM python:3.11-slim AS backend-builder
|
|
|
|
# Re-declare ARG inside the stage (Docker scoping requirement).
|
|
ARG PYTORCH_VARIANT=cpu
|
|
|
|
WORKDIR /build
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
git \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN pip install --no-cache-dir --upgrade pip
|
|
|
|
COPY backend/requirements.txt .
|
|
|
|
# ROCm wheel index. Default 6.3 (RDNA1/2/3); set ROCM_VERSION=7.2 for RDNA4.
|
|
ARG ROCM_VERSION=6.3
|
|
|
|
# For ROCm, make the PyTorch ROCm index primary so every install below resolves
|
|
# torch to ROCm wheels instead of the default CUDA build.
|
|
RUN if [ "$PYTORCH_VARIANT" = "rocm" ]; then \
|
|
pip install --no-cache-dir --prefix=/install \
|
|
--index-url "https://download.pytorch.org/whl/rocm${ROCM_VERSION}" \
|
|
torch torchaudio && \
|
|
printf '[global]\nindex-url = https://download.pytorch.org/whl/rocm%s\nextra-index-url = https://pypi.org/simple\n' "$ROCM_VERSION" > /etc/pip.conf; \
|
|
fi
|
|
|
|
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
|
|
RUN pip install --no-cache-dir --prefix=/install --no-deps chatterbox-tts
|
|
RUN pip install --no-cache-dir --prefix=/install --no-deps hume-tada
|
|
RUN pip install --no-cache-dir --prefix=/install \
|
|
git+https://github.com/QwenLM/Qwen3-TTS.git
|
|
|
|
|
|
# === Stage 3: Runtime ===
|
|
FROM python:3.11-slim
|
|
|
|
# Create non-root user; the entrypoint joins GPU device groups at runtime.
|
|
RUN groupadd -r talkbox && \
|
|
useradd -r -g talkbox -m -s /bin/bash talkbox
|
|
|
|
WORKDIR /app
|
|
|
|
# Install only runtime system dependencies (gosu drops root in the entrypoint)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ffmpeg \
|
|
curl \
|
|
gosu \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy installed Python packages from builder stage
|
|
COPY --from=backend-builder /install /usr/local
|
|
|
|
# Copy backend application code
|
|
COPY --chown=talkbox:talkbox backend/ /app/backend/
|
|
|
|
# Copy built frontend from frontend stage
|
|
COPY --from=frontend --chown=talkbox:talkbox /build/web/dist /app/frontend/
|
|
|
|
# Create data directories owned by non-root user
|
|
RUN mkdir -p /app/data/generations /app/data/profiles /app/data/cache \
|
|
&& chown -R talkbox:talkbox /app/data
|
|
|
|
# Expose the API port
|
|
EXPOSE 17494
|
|
|
|
# Health check — auto-restart if the server hangs
|
|
HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=60s \
|
|
CMD curl -f http://localhost:17494/health || exit 1
|
|
|
|
# Entrypoint joins GPU groups then drops to the talkbox user.
|
|
# Normalize CRLF (a Windows checkout otherwise leaves the shebang as
|
|
# `#!/bin/sh\r`, which Linux can't resolve — reported as a misleading
|
|
# "no such file or directory" even though the file exists).
|
|
COPY --chmod=755 scripts/rocm-entrypoint.sh /usr/local/bin/entrypoint.sh
|
|
RUN sed -i 's/\r$//' /usr/local/bin/entrypoint.sh
|
|
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
|
CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "17494"]
|