blob: eaedc7f174d3a717fc438d5f444c334b12ff008a (
plain) (
blame)
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
|
# Build on the same Debian release as the runtime image. This pins glibc,
# libssl and libopus, so a binary built on a rolling-release host (Arch, etc.)
# no longer fails on Debian due to newer toolchain/glibc symbols.
FROM rust:1-trixie AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Build dependencies:
# - cmake + clang + libclang-dev: espeak-rs-sys (pulled in by piper-rs) builds
# espeak-ng and runs bindgen
# - pkg-config + libopus-dev: libopus_sys
# - libssl-dev: native-tls / openssl-sys
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
cmake \
clang \
libclang-dev \
pkg-config \
libopus-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Compile the dependency graph once with a dummy main so source edits do not
# invalidate the expensive piper/espeak/onnxruntime build.
COPY Cargo.toml Cargo.lock build.rs ./
RUN mkdir src \
&& printf 'fn main() {}\n' > src/main.rs \
&& cargo build --release \
&& rm -rf src
COPY src ./src
RUN cargo build --release
# ── Runtime ───────────────────────────────────────────────────────────
FROM debian:trixie-slim
ENV DEBIAN_FRONTEND=noninteractive
# Runtime libraries reported by `readelf -d`: libstdc++, libopus, libssl,
# libcrypto. ffmpeg/qalc/yt-dlp are invoked as subprocesses.
# Full python3 (not python3-minimal) is required by the yt-dlp zipapp.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
ffmpeg \
libopus0 \
libssl3t64 \
libstdc++6 \
passwd \
python3 \
qalc \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# yt-dlp is distributed as a self-contained Python zipapp; using the latest
# release avoids the stale Debian package breaking on YouTube changes.
ADD https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp /usr/local/bin/yt-dlp
RUN chmod 755 /usr/local/bin/yt-dlp
RUN useradd --create-home --uid 1000 --shell /usr/sbin/nologin bot \
&& mkdir -p /app/data /app/piper /tmp/senator_sperma \
&& chown -R bot:bot /app /tmp/senator_sperma
WORKDIR /app
COPY --from=builder /app/target/release/senator-sperma /usr/local/bin/senator-sperma
USER bot
ENV TZ=Europe/Warsaw \
TTS_MODEL_PATH=/app/piper \
RUST_LOG=info \
HOME=/home/bot
ENTRYPOINT ["/usr/local/bin/senator-sperma"]
|