Die bisherigen Patches zielten auf Muster, die in oauth/src/lib.rs nicht vorhanden sind. Der tatsächliche Bind-Aufruf ist TcpListener::bind(socket_address) – dieser wird jetzt direkt durch SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, port) ersetzt. Dadurch ist der OAuth-Callback-Server unter http://<ha-ip>:5588 erreichbar. Der Benutzer ersetzt nach der Spotify-Weiterleitung 127.0.0.1 durch die HA-IP in der Adressleiste. run.sh erkennt die HA-IP automatisch und zeigt eine klare Schritt-für-Schritt-Anleitung beim ersten Start. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
74 lines
2.7 KiB
Docker
74 lines
2.7 KiB
Docker
ARG BUILD_FROM
|
|
|
|
# ============================================================
|
|
# Build stage: Librespot aus Rust-Quellcode kompilieren
|
|
# ============================================================
|
|
FROM rust:alpine AS librespot-builder
|
|
|
|
RUN apk add --no-cache \
|
|
musl-dev \
|
|
pkgconfig \
|
|
openssl-dev \
|
|
openssl-libs-static \
|
|
git
|
|
|
|
# Librespot aus dem Git-Tag klonen, patchen und kompilieren.
|
|
#
|
|
# Patch: OAuth-Server bindet an 0.0.0.0 statt 127.0.0.1.
|
|
# Standard: 127.0.0.1 → nur vom HA-Host selbst erreichbar.
|
|
# Mit 0.0.0.0 → der OAuth-Flow ist im Browser aus dem Heimnetz zugänglich.
|
|
#
|
|
# --locked: verwendet das originale Cargo.lock aus dem Tag (pinnt vergen-gitcl
|
|
# auf 0.x und vermeidet so den vergen_lib Versionskonflikt mit 9.x).
|
|
RUN git clone --depth 1 --branch v0.7.0 \
|
|
https://github.com/librespot-org/librespot.git /build && \
|
|
cd /build && \
|
|
# OAuth-Server auf allen Interfaces binden (statt nur 127.0.0.1).
|
|
# get_authcode_listener() bestimmt die Bind-Adresse aus dem redirect_uri-Parameter.
|
|
# Wir patchen den TcpListener::bind-Aufruf direkt, sodass er immer an 0.0.0.0
|
|
# bindet (mit dem gleichen Port wie im redirect_uri angegeben).
|
|
# Außerdem ersetzen wir die englische Browser-Meldung durch eine deutsche.
|
|
sed -i \
|
|
-e 's/TcpListener::bind(socket_address)/TcpListener::bind(std::net::SocketAddrV4::new(std::net::Ipv4Addr::UNSPECIFIED, socket_address.port()))/' \
|
|
-e 's/Go back to your terminal :)/Autorisierung erfolgreich! Du kannst diesen Tab schliessen./' \
|
|
oauth/src/lib.rs && \
|
|
echo "--- oauth/src/lib.rs (Patch-Zeilen) ---" && \
|
|
grep -n "UNSPECIFIED\|Autorisierung\|SocketAddrV4" oauth/src/lib.rs || true && \
|
|
cargo build \
|
|
--release \
|
|
--locked \
|
|
--no-default-features \
|
|
--features "native-tls" && \
|
|
mkdir -p /install/bin && \
|
|
cp target/release/librespot /install/bin/librespot
|
|
|
|
# ============================================================
|
|
# Runtime stage: HA-Basis-Image + ffmpeg + icecast
|
|
# ============================================================
|
|
FROM ${BUILD_FROM}
|
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
# Abhängigkeiten installieren
|
|
# icecast liegt in Alpine's Community-Repository
|
|
RUN apk add --no-cache \
|
|
bash \
|
|
jq \
|
|
curl \
|
|
python3 \
|
|
ffmpeg \
|
|
&& apk add --no-cache \
|
|
--repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \
|
|
icecast \
|
|
|| apk add --no-cache icecast
|
|
|
|
# Librespot-Binary aus dem Build-Stage übernehmen
|
|
COPY --from=librespot-builder /install/bin/librespot /usr/local/bin/librespot
|
|
RUN chmod +x /usr/local/bin/librespot
|
|
|
|
# Add-on Dateien kopieren
|
|
COPY run.sh /run.sh
|
|
RUN chmod a+x /run.sh
|
|
|
|
CMD ["/run.sh"]
|