FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim # PipeWire client tools — pw-play connects to the host's PipeWire socket # pulseaudio-utils provides pactl for media ducking (volume control via PulseAudio compat) # ffmpeg handles WAV→{mp3,ogg,flac,m4a} conversion for generate_audio's format param RUN apt-get update && apt-get install -y --no-install-recommends \ pipewire-bin \ pulseaudio-utils \ ffmpeg \ && rm -rf /var/lib/apt/lists/* WORKDIR /app ENV UV_COMPILE_BYTECODE=1 # Create venv RUN uv venv # Install CPU-only torch first (saves ~3GB vs CUDA — SNAC runs on CPU anyway) RUN --mount=type=cache,target=/root/.cache/uv \ uv pip install torch --index-url https://download.pytorch.org/whl/cpu # Install project dependencies (torch already satisfied, won't redownload) COPY pyproject.toml ./ RUN --mount=type=cache,target=/root/.cache/uv \ uv pip install --no-deps -r pyproject.toml 2>/dev/null || true # Copy source and install project COPY src/ src/ RUN --mount=type=cache,target=/root/.cache/uv \ uv pip install . # Non-root user matching host uid for PipeWire socket access RUN useradd -u 1000 -m tts \ && mkdir -p /home/tts/.cache/huggingface /data \ && chown -R tts:tts /home/tts/.cache /data USER tts ENV PATH="/app/.venv/bin:$PATH" EXPOSE 8371 HEALTHCHECK --interval=30s --timeout=5s --start-period=15s \ CMD python -c "import socket; s=socket.create_connection(('127.0.0.1',8371),2); s.close()" || exit 1 CMD ["mcspeak"]