aboutsummaryrefslogtreecommitdiffstats
path: root/Dockerfile
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-27 18:35:58 +0100
committersalmonik <salmonik@tuta.io>2026-10-27 18:35:58 +0100
commita82489c95f8c8f3e55f92939224599598bd0de96 (patch)
tree59591c88cede5a3aef8255fad713ddd9b329709c /Dockerfile
parentmusic: group playback commands under /music (diff)
downloadsenator-sperma-a82489c95f8c8f3e55f92939224599598bd0de96.tar.gz
senator-sperma-a82489c95f8c8f3e55f92939224599598bd0de96.zip
docker: build and run on Debian trixie
Add a multi-stage image that compiles inside Debian trixie and runs on the same glibc/libssl/libopus, avoiding the Arch-built binary failing on Debian. The runtime image installs ffmpeg, qalc, the shared libraries, and the latest yt-dlp zipapp, and runs as uid 1000. compose.yaml mounts data/ and piper/, overrides TTS_MODEL_PATH for the container layout, and builds with host networking because the default Docker bridge DNS cannot resolve crates.io or deb.debian.org on this host.
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile76
1 files changed, 76 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..eaedc7f
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,76 @@
1# Build on the same Debian release as the runtime image. This pins glibc,
2# libssl and libopus, so a binary built on a rolling-release host (Arch, etc.)
3# no longer fails on Debian due to newer toolchain/glibc symbols.
4FROM rust:1-trixie AS builder
5
6ENV DEBIAN_FRONTEND=noninteractive
7
8# Build dependencies:
9# - cmake + clang + libclang-dev: espeak-rs-sys (pulled in by piper-rs) builds
10# espeak-ng and runs bindgen
11# - pkg-config + libopus-dev: libopus_sys
12# - libssl-dev: native-tls / openssl-sys
13RUN apt-get update \
14 && apt-get install -y --no-install-recommends \
15 cmake \
16 clang \
17 libclang-dev \
18 pkg-config \
19 libopus-dev \
20 libssl-dev \
21 && rm -rf /var/lib/apt/lists/*
22
23WORKDIR /app
24
25# Compile the dependency graph once with a dummy main so source edits do not
26# invalidate the expensive piper/espeak/onnxruntime build.
27COPY Cargo.toml Cargo.lock build.rs ./
28RUN mkdir src \
29 && printf 'fn main() {}\n' > src/main.rs \
30 && cargo build --release \
31 && rm -rf src
32
33COPY src ./src
34RUN cargo build --release
35
36# ── Runtime ───────────────────────────────────────────────────────────
37FROM debian:trixie-slim
38
39ENV DEBIAN_FRONTEND=noninteractive
40
41# Runtime libraries reported by `readelf -d`: libstdc++, libopus, libssl,
42# libcrypto. ffmpeg/qalc/yt-dlp are invoked as subprocesses.
43# Full python3 (not python3-minimal) is required by the yt-dlp zipapp.
44RUN apt-get update \
45 && apt-get install -y --no-install-recommends \
46 ca-certificates \
47 ffmpeg \
48 libopus0 \
49 libssl3t64 \
50 libstdc++6 \
51 passwd \
52 python3 \
53 qalc \
54 tzdata \
55 && rm -rf /var/lib/apt/lists/*
56
57# yt-dlp is distributed as a self-contained Python zipapp; using the latest
58# release avoids the stale Debian package breaking on YouTube changes.
59ADD https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/local/bin/yt-dlp
60RUN chmod 755 /usr/local/bin/yt-dlp
61
62RUN useradd --create-home --uid 1000 --shell /usr/sbin/nologin bot \
63 && mkdir -p /app/data /app/piper /tmp/senator_sperma \
64 && chown -R bot:bot /app /tmp/senator_sperma
65
66WORKDIR /app
67COPY --from=builder /app/target/release/senator-sperma /usr/local/bin/senator-sperma
68
69USER bot
70
71ENV TZ=Europe/Warsaw \
72 TTS_MODEL_PATH=/app/piper \
73 RUST_LOG=info \
74 HOME=/home/bot
75
76ENTRYPOINT ["/usr/local/bin/senator-sperma"]