-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.demo
More file actions
650 lines (548 loc) · 24.7 KB
/
Dockerfile.demo
File metadata and controls
650 lines (548 loc) · 24.7 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# SPDX-FileCopyrightText: © 2025 StreamKit Contributors
#
# SPDX-License-Identifier: MPL-2.0
# Demo image: CPU-only with all core plugins (including Pocket TTS and Supertonic) and sample pipelines
# syntax=docker/dockerfile:1
# Version configuration
ARG SHERPA_ONNX_VERSION=1.12.17
# Stage 1: Build Rust dependencies
FROM rust:1.92-slim-bookworm AS rust-deps
WORKDIR /build
# Install build dependencies (includes all deps needed by workspace plugins)
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
g++ \
cmake \
libopus-dev \
libvpx-dev \
libclang-dev \
clang \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy workspace files to build dependencies (plugins are now excluded)
COPY Cargo.toml Cargo.lock ./
COPY apps ./apps
COPY crates ./crates
COPY sdks ./sdks
COPY wit ./wit
COPY assets ./assets
# Create dummy ui/dist directory so server's RustEmbed doesn't fail
# (will be replaced with real UI in Stage 3)
RUN mkdir -p ui/dist && echo '<!DOCTYPE html><html><body>Building...</body></html>' > ui/dist/index.html
# Build dependencies with cache mount (plugins are excluded from workspace)
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/target \
cargo build --profile release-lto -p streamkit-server --bin skit --features "moq" && \
# Copy compiled artifacts out of cache mount so they persist in the layer
mkdir -p /build/target-out && \
cp -r /build/target/release-lto /build/target-out/
# Stage 2: Build UI
FROM oven/bun:1.3.5-alpine AS ui-builder
WORKDIR /build/ui
# Install UI dependencies
COPY ui/package.json ui/bun.lock* ./
RUN --mount=type=cache,target=/root/.bun/install/cache \
bun install --frozen-lockfile
# Copy UI source and build
COPY ui/ ./
RUN bun run build
# Stage 3: Build final server binary with UI embedded
FROM rust:1.92-slim-bookworm AS rust-builder
WORKDIR /build
# Install build dependencies (same as stage 1, includes all deps needed by workspace)
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
g++ \
cmake \
libopus-dev \
libvpx-dev \
libclang-dev \
clang \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy workspace files (plugins are excluded from workspace)
COPY Cargo.toml Cargo.lock ./
COPY apps ./apps
COPY crates ./crates
COPY sdks ./sdks
COPY wit ./wit
COPY assets ./assets
# Copy built UI from stage 2
COPY --from=ui-builder /build/ui/dist ./ui/dist
# Remove the server binary from the previous stage to force rebuild with new UI
# We'll use cache mount with artifacts from stage 1
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/target \
--mount=type=bind,from=rust-deps,source=/build/target-out/release-lto,target=/build/target-init \
bash -c '\
# Copy pre-built dependencies if target is empty (first build) \
if [ ! -d "/build/target/release-lto/deps" ]; then \
echo "Initializing target from cache..."; \
mkdir -p /build/target/release-lto; \
cp -r /build/target-init/* /build/target/release-lto/ || true; \
fi; \
# Remove server binary to force rebuild with new UI \
rm -rf /build/target/release-lto/skit \
/build/target/release-lto/skit.d \
/build/target/release-lto/deps/streamkit_server-* \
/build/target/release-lto/.fingerprint/streamkit-server-*; \
# Build only the server binary \
cargo build --profile release-lto --features "moq" --bin skit; \
# Copy final binary out of cache mount \
mkdir -p /build/bin && cp /build/target/release-lto/skit /build/bin/skit \
'
# Stage 4: Build Whisper plugin
FROM rust:1.92-slim-bookworm AS whisper-builder
WORKDIR /build
# Install build dependencies for whisper.cpp
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
g++ \
cmake \
curl \
libclang-dev \
clang \
git \
&& rm -rf /var/lib/apt/lists/*
# whisper.cpp/ggml defaults to enabling `GGML_NATIVE` (i.e. `-march=native`) when not cross-compiling.
# That can produce binaries that crash with SIGILL on older CPUs. Setting SOURCE_DATE_EPOCH disables
# `GGML_NATIVE_DEFAULT` upstream, making the build portable by default.
ENV SOURCE_DATE_EPOCH=1
# Extra defense-in-depth: ensure the toolchain doesn't auto-enable newer x86 features.
ENV CFLAGS="-O3 -pipe -fPIC -march=x86-64 -mtune=generic" \
CXXFLAGS="-O3 -pipe -fPIC -march=x86-64 -mtune=generic"
# Copy only what's needed to build whisper plugin
# Note: Cargo.toml needed for workspace dependency resolution in core/
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/whisper ./plugins/native/whisper
# Build whisper plugin
RUN --mount=type=cache,id=cargo-registry-whisper,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-whisper,target=/usr/local/cargo/git \
--mount=type=cache,id=whisper-target-portable-v2,target=/build/plugins/native/whisper/target-portable \
cd plugins/native/whisper && \
cargo build --release --target-dir target-portable && \
mkdir -p /build/plugins/native && \
cp target-portable/release/libwhisper.so /build/plugins/native/
# Download Whisper models (demo image uses a single tiny multilingual model).
# - ggml-tiny-q5_1.bin: Tiny multilingual STT (quantized)
# NOTE: This model is not yet uploaded to streamkit/whisper-models, using original source
# - silero_vad.onnx: VAD model for Whisper
RUN mkdir -p /build/models && \
curl -L -o /build/models/ggml-tiny-q5_1.bin \
https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny-q5_1.bin && \
curl -L -o /build/models/silero_vad.onnx \
https://huggingface.co/streamkit/whisper-models/resolve/main/silero_vad.onnx
# Stage 5: Build Kokoro TTS plugin
FROM rust:1.92-slim-bookworm AS kokoro-builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
wget \
bzip2 \
libclang-dev \
clang \
&& rm -rf /var/lib/apt/lists/*
# Download and install sherpa-onnx shared library
ARG SHERPA_ONNX_VERSION
RUN cd /tmp && \
wget https://github.com/k2-fsa/sherpa-onnx/releases/download/v${SHERPA_ONNX_VERSION}/sherpa-onnx-v${SHERPA_ONNX_VERSION}-linux-x64-shared.tar.bz2 && \
tar xf sherpa-onnx-v${SHERPA_ONNX_VERSION}-linux-x64-shared.tar.bz2 && \
cp sherpa-onnx-v${SHERPA_ONNX_VERSION}-linux-x64-shared/lib/*.so* /usr/local/lib/ && \
ldconfig
# Copy only what's needed to build kokoro plugin
# Note: Cargo.toml needed for workspace dependency resolution in core/
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/kokoro ./plugins/native/kokoro
# Build kokoro plugin
RUN --mount=type=cache,id=cargo-registry-kokoro,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-kokoro,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/plugins/native/kokoro/target \
cd plugins/native/kokoro && \
RUSTFLAGS="-L /usr/local/lib" cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libkokoro.so /build/plugins/native/
# Download Kokoro TTS models
RUN mkdir -p /build/models && \
cd /build/models && \
curl -L -o kokoro-multi-lang-v1_1.tar.bz2 \
https://huggingface.co/streamkit/kokoro-models/resolve/main/kokoro-multi-lang-v1_1.tar.bz2 && \
tar xf kokoro-multi-lang-v1_1.tar.bz2 && \
rm kokoro-multi-lang-v1_1.tar.bz2
# Stage 6: Build Piper TTS plugin
FROM rust:1.92-slim-bookworm AS piper-builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
wget \
bzip2 \
libclang-dev \
clang \
&& rm -rf /var/lib/apt/lists/*
# Copy sherpa-onnx from kokoro-builder (reuse to avoid duplicate downloads)
COPY --from=kokoro-builder /usr/local/lib/*.so* /usr/local/lib/
RUN ldconfig
# Copy only what's needed to build piper plugin
# Note: Cargo.toml needed for workspace dependency resolution in core/
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/piper ./plugins/native/piper
# Build piper plugin
RUN --mount=type=cache,id=cargo-registry-piper,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-piper,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/plugins/native/piper/target \
cd plugins/native/piper && \
RUSTFLAGS="-L /usr/local/lib" cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libpiper.so /build/plugins/native/
# Download Piper TTS models (English + Spanish for translation output)
RUN mkdir -p /build/models && \
cd /build/models && \
curl -L -o vits-piper-en_US-libritts_r-medium.tar.bz2 \
https://huggingface.co/streamkit/piper-models/resolve/main/vits-piper-en_US-libritts_r-medium.tar.bz2 && \
tar xf vits-piper-en_US-libritts_r-medium.tar.bz2 && \
rm vits-piper-en_US-libritts_r-medium.tar.bz2 && \
cd vits-piper-en_US-libritts_r-medium && \
if [ ! -f "model.onnx" ] && [ -f "en_US-libritts_r-medium.onnx" ]; then \
ln -sf en_US-libritts_r-medium.onnx model.onnx; \
fi && \
cd /build/models && \
curl -L -o vits-piper-es_MX-claude-high.tar.bz2 \
https://huggingface.co/streamkit/piper-models/resolve/main/vits-piper-es_MX-claude-high.tar.bz2 && \
tar xf vits-piper-es_MX-claude-high.tar.bz2 && \
rm vits-piper-es_MX-claude-high.tar.bz2 && \
cd vits-piper-es_MX-claude-high && \
if [ ! -f "model.onnx" ] && [ -f "es_MX-claude-high.onnx" ]; then \
ln -sf es_MX-claude-high.onnx model.onnx; \
fi
# Stage 7: Build SenseVoice STT plugin
FROM rust:1.92-slim-bookworm AS sensevoice-builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
wget \
bzip2 \
libclang-dev \
clang \
&& rm -rf /var/lib/apt/lists/*
# Copy sherpa-onnx from kokoro-builder (reuse to avoid duplicate downloads)
COPY --from=kokoro-builder /usr/local/lib/*.so* /usr/local/lib/
RUN ldconfig
# Copy only what's needed to build sensevoice plugin
# Note: Cargo.toml needed for workspace dependency resolution in core/
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/sensevoice ./plugins/native/sensevoice
# Build sensevoice plugin
RUN --mount=type=cache,id=cargo-registry-sensevoice,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-sensevoice,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/plugins/native/sensevoice/target \
cd plugins/native/sensevoice && \
RUSTFLAGS="-L /usr/local/lib" cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libsensevoice.so /build/plugins/native/
# Download SenseVoice models
RUN mkdir -p /build/models && \
cd /build/models && \
curl -L -o sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09.tar.bz2 \
https://huggingface.co/streamkit/sensevoice-models/resolve/main/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09.tar.bz2 && \
tar xf sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09.tar.bz2 && \
rm sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09.tar.bz2
# Stage 8: Build VAD plugin
FROM rust:1.92-slim-bookworm AS vad-builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
wget \
bzip2 \
libclang-dev \
clang \
&& rm -rf /var/lib/apt/lists/*
# Copy sherpa-onnx from kokoro-builder (reuse to avoid duplicate downloads)
COPY --from=kokoro-builder /usr/local/lib/*.so* /usr/local/lib/
RUN ldconfig
# Copy only what's needed to build vad plugin
# Note: Cargo.toml needed for workspace dependency resolution in core/
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/vad ./plugins/native/vad
# Build vad plugin
RUN --mount=type=cache,id=cargo-registry-vad,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-vad,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/plugins/native/vad/target \
cd plugins/native/vad && \
RUSTFLAGS="-L /usr/local/lib" cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libvad.so /build/plugins/native/
# Download ten-vad model
RUN mkdir -p /build/models && \
curl -L -o /build/models/ten-vad.onnx \
https://huggingface.co/streamkit/vad-models/resolve/main/ten-vad.onnx
# Stage 9: Build Matcha TTS plugin
FROM rust:1.92-slim-bookworm AS matcha-builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
curl \
wget \
bzip2 \
libclang-dev \
clang \
&& rm -rf /var/lib/apt/lists/*
# Copy sherpa-onnx from kokoro-builder (reuse to avoid duplicate downloads)
COPY --from=kokoro-builder /usr/local/lib/*.so* /usr/local/lib/
RUN ldconfig
# Copy only what's needed to build matcha plugin
# Note: Cargo.toml needed for workspace dependency resolution in core/
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/matcha ./plugins/native/matcha
# Build matcha plugin
RUN --mount=type=cache,id=cargo-registry-matcha,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-matcha,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/plugins/native/matcha/target \
cd plugins/native/matcha && \
RUSTFLAGS="-L /usr/local/lib" cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libmatcha.so /build/plugins/native/
# Download Matcha TTS models
RUN mkdir -p /build/models && \
cd /build/models && \
curl -L -o matcha-icefall-en_US-ljspeech.tar.bz2 \
https://huggingface.co/streamkit/matcha-models/resolve/main/matcha-icefall-en_US-ljspeech.tar.bz2 && \
tar xf matcha-icefall-en_US-ljspeech.tar.bz2 && \
rm matcha-icefall-en_US-ljspeech.tar.bz2 && \
cd matcha-icefall-en_US-ljspeech && \
curl -L -o vocos-22khz-univ.onnx \
https://huggingface.co/streamkit/matcha-models/resolve/main/matcha-icefall-en_US-ljspeech/vocos-22khz-univ.onnx
# Stage 10: Build Helsinki Translation plugin (CPU-only)
FROM rust:1.92-slim-bookworm AS helsinki-builder
WORKDIR /build
# Install dependencies (Rust + Python for model conversion)
RUN apt-get update && apt-get install -y \
curl \
git \
pkg-config \
libssl-dev \
libclang-dev \
clang \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Copy only what's needed to build helsinki plugin
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/helsinki ./plugins/native/helsinki
# Build helsinki plugin (CPU-only, no cuda feature)
RUN --mount=type=cache,id=helsinki-cargo-registry,target=/usr/local/cargo/registry \
--mount=type=cache,id=helsinki-cargo-git,target=/usr/local/cargo/git \
--mount=type=cache,id=helsinki-target,target=/build/plugins/native/helsinki/target \
cd plugins/native/helsinki && \
cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libhelsinki.so /build/plugins/native/
# Download and convert OPUS-MT models (EN<->ES)
RUN PIP_BREAK_SYSTEM_PACKAGES=1 pip3 install --no-cache-dir \
transformers \
sentencepiece \
safetensors \
torch \
tokenizers && \
python3 plugins/native/helsinki/download-models.py
# Stage 11: Build Pocket TTS plugin
FROM rust:1.92-slim-bookworm AS pocket-tts-builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
g++ \
cmake \
curl \
bzip2 \
libclang-dev \
clang \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy only what's needed to build pocket-tts plugin
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/pocket-tts ./plugins/native/pocket-tts
# Build pocket-tts plugin
RUN --mount=type=cache,id=cargo-registry-pocket-tts,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-pocket-tts,target=/usr/local/cargo/git \
--mount=type=cache,id=pocket-tts-target,target=/build/plugins/native/pocket-tts/target \
cd plugins/native/pocket-tts && \
cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libpocket_tts.so /build/plugins/native/
# Download Pocket TTS models
RUN mkdir -p /build/models && \
cd /build/models && \
curl -L -o pocket-tts-b6369a24.tar.bz2 \
https://huggingface.co/streamkit/pocket-tts-models/resolve/main/pocket-tts-b6369a24.tar.bz2 && \
tar xf pocket-tts-b6369a24.tar.bz2 && \
rm pocket-tts-b6369a24.tar.bz2
# Stage 12: Build Supertonic TTS plugin
FROM rust:1.92-slim-bookworm AS supertonic-builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
g++ \
cmake \
curl \
bzip2 \
libclang-dev \
clang \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy only what's needed to build supertonic plugin
COPY Cargo.toml Cargo.lock ./
COPY crates/core ./crates/core
COPY sdks/plugin-sdk ./sdks/plugin-sdk
COPY plugins/native/supertonic ./plugins/native/supertonic
# Build supertonic plugin
RUN --mount=type=cache,id=cargo-registry-supertonic,target=/usr/local/cargo/registry \
--mount=type=cache,id=cargo-git-supertonic,target=/usr/local/cargo/git \
--mount=type=cache,id=supertonic-target,target=/build/plugins/native/supertonic/target \
cd plugins/native/supertonic && \
cargo build --release --target-dir target && \
mkdir -p /build/plugins/native && \
cp target/release/libsupertonic.so /build/plugins/native/
# Download Supertonic models
RUN mkdir -p /build/models && \
cd /build/models && \
curl -L -o supertonic-v2-onnx.tar.bz2 \
https://huggingface.co/streamkit/supertonic-models/resolve/main/supertonic-v2-onnx.tar.bz2 && \
tar xf supertonic-v2-onnx.tar.bz2 && \
rm supertonic-v2-onnx.tar.bz2
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies (include gdb for debugging demo image crashes)
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libopus0 \
libvpx7 \
libgomp1 \
gdb \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create app user
RUN useradd -m -u 1000 -s /bin/bash app
# Copy binary from rust builder
COPY --from=rust-builder /build/bin/skit /usr/local/bin/skit
# Copy sherpa-onnx shared libraries from kokoro-builder
COPY --from=kokoro-builder /usr/local/lib/*.so* /usr/local/lib/
RUN ldconfig
# Copy whisper plugin and models
# IMPORTANT: Use --chown=app:app on every COPY to avoid a bulk `chown -R` later
# which would duplicate every file in a new layer (~12GB waste).
COPY --chown=app:app --from=whisper-builder /build/plugins /opt/streamkit/plugins
COPY --chown=app:app --from=whisper-builder /build/models /opt/streamkit/models
# Copy kokoro plugin and models (merge into /opt/streamkit/plugins and /opt/streamkit/models)
COPY --chown=app:app --from=kokoro-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=kokoro-builder /build/models/kokoro-multi-lang-v1_1 /opt/streamkit/models/kokoro-multi-lang-v1_1
# Copy piper plugin and models (merge into /opt/streamkit/plugins and /opt/streamkit/models)
COPY --chown=app:app --from=piper-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=piper-builder /build/models/vits-piper-en_US-libritts_r-medium /opt/streamkit/models/vits-piper-en_US-libritts_r-medium
COPY --chown=app:app --from=piper-builder /build/models/vits-piper-es_MX-claude-high /opt/streamkit/models/vits-piper-es_MX-claude-high
# Copy sensevoice plugin and models (merge into /opt/streamkit/plugins and /opt/streamkit/models)
COPY --chown=app:app --from=sensevoice-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=sensevoice-builder /build/models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09 /opt/streamkit/models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-int8-2025-09-09
# Copy helsinki plugin and models
COPY --chown=app:app --from=helsinki-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=helsinki-builder /build/models/opus-mt-en-es /opt/streamkit/models/opus-mt-en-es
COPY --chown=app:app --from=helsinki-builder /build/models/opus-mt-es-en /opt/streamkit/models/opus-mt-es-en
# Copy vad plugin and model (merge into /opt/streamkit/plugins and /opt/streamkit/models)
COPY --chown=app:app --from=vad-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=vad-builder /build/models/ten-vad.onnx /opt/streamkit/models/ten-vad.onnx
# Copy matcha plugin and models (merge into /opt/streamkit/plugins and /opt/streamkit/models)
COPY --chown=app:app --from=matcha-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=matcha-builder /build/models/matcha-icefall-en_US-ljspeech /opt/streamkit/models/matcha-icefall-en_US-ljspeech
# Copy pocket-tts plugin and models
COPY --chown=app:app --from=pocket-tts-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=pocket-tts-builder /build/models/pocket-tts /opt/streamkit/models/pocket-tts
# Copy supertonic plugin and models
COPY --chown=app:app --from=supertonic-builder /build/plugins/native/* /opt/streamkit/plugins/native/
COPY --chown=app:app --from=supertonic-builder /build/models/supertonic-v2-onnx /opt/streamkit/models/supertonic-v2-onnx
# Copy sample pipelines + small bundled audio samples (Opus/Ogg only)
COPY --chown=app:app samples/pipelines /opt/streamkit/samples/pipelines
COPY --chown=app:app samples/audio/system/*.ogg samples/audio/system/*.ogg.license /opt/streamkit/samples/audio/system/
COPY --chown=app:app samples/audio/system/*.opus samples/audio/system/*.opus.license /opt/streamkit/samples/audio/system/
# Demo image uses a single tiny multilingual Whisper model, but the committed sample pipelines
# reference a mix of base.en/tiny.en/multilingual model filenames. Rewrite them inside the image
# so the shipped samples work without bundling multiple Whisper models.
RUN find /opt/streamkit/samples/pipelines -type f \( -name '*.yml' -o -name '*.yaml' \) -print0 | \
xargs -0 sed -i \
-e 's#models/ggml-base\.en-q5_1\.bin#models/ggml-tiny-q5_1.bin#g' \
-e 's#models/ggml-tiny\.en-q5_1\.bin#models/ggml-tiny-q5_1.bin#g' \
-e 's#models/ggml-base-q5_1\.bin#models/ggml-tiny-q5_1.bin#g' && \
rm -f \
/opt/streamkit/samples/pipelines/oneshot/speech_to_text_translate.yml \
/opt/streamkit/samples/pipelines/oneshot/gain_filter_rust.yml \
/opt/streamkit/samples/pipelines/dynamic/speech-translate-en-es.yaml \
/opt/streamkit/samples/pipelines/dynamic/speech-translate-es-en.yaml && \
chown -R app:app /opt/streamkit/samples/pipelines
# Copy demo configuration
COPY --chown=app:app docker-skit-demo.toml /opt/streamkit/config/skit.toml
# Create runtime-writable directories and compatibility symlinks.
# No bulk chown needed — all COPY instructions above use --chown=app:app.
RUN mkdir -p /opt/streamkit/.plugins /opt/streamkit/logs /opt/streamkit/config /opt/streamkit/demo && \
chown app:app /opt/streamkit/.plugins /opt/streamkit/logs /opt/streamkit/config /opt/streamkit/demo && \
mkdir -p /app && \
ln -sfn /opt/streamkit/config/skit.toml /opt/streamkit/skit.toml && \
ln -sfn /opt/streamkit/plugins /app/plugins && \
ln -sfn /opt/streamkit/models /app/models && \
ln -sfn /opt/streamkit/samples /app/samples && \
ln -sfn /opt/streamkit/config /app/config && \
ln -sfn /opt/streamkit/.plugins /app/.plugins && \
ln -sfn /opt/streamkit/logs /app/logs
WORKDIR /opt/streamkit
USER app
# Expose HTTP and UDP ports
EXPOSE 4545/tcp
EXPOSE 4545/udp
# OCI image labels
LABEL org.opencontainers.image.title="StreamKit Demo"
LABEL org.opencontainers.image.description="Demo image with pre-configured plugins for speech-to-text, text-to-speech, and translation"
LABEL org.opencontainers.image.source="https://github.com/streamer45/streamkit"
LABEL org.opencontainers.image.licenses="MPL-2.0"
LABEL org.opencontainers.image.vendor="StreamKit Contributors"
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD curl -f http://localhost:4545/healthz || exit 1
# Default command
CMD ["skit", "serve"]