From 4b6be075c1d04dc981ace483b7737c543935b349 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Sat, 26 Aug 2023 23:40:56 +0200 Subject: [PATCH] Updated to work on a raspberry pi --- Dockerfile | 37 ++++++++++++++++++------------------- README.md | 12 ++++++++---- build.sh | 3 +++ docker-compose.yml | 1 - start.sh | 12 +++++++++++- 5 files changed, 40 insertions(+), 25 deletions(-) create mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile index 3ce4c5a..b741d82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,25 @@ -FROM rust as build +FROM --platform=$BUILDPLATFORM debian:bullseye-slim as build -WORKDIR /build - -RUN apt-get -yqq update && \ - apt-get install --no-install-recommends -yqq libasound2-dev && \ - git clone --branch=master https://github.com/Spotifyd/spotifyd.git . - -RUN cargo build --release --features alsa_backend - -FROM debian:bullseye-slim +ENV SPOTIFYD_VERSION=v0.3.5 +ENV URL=https://github.com/Spotifyd/spotifyd/releases/download/${SPOTIFYD_VERSION}/spotifyd-linux-armhf-full.tar.gz RUN apt-get update && \ - apt-get install -yqq --no-install-recommends libasound2 alsa-utils && \ - rm -rf /var/lib/apt/lists/* && \ - groupadd -r spotify && \ - useradd --no-log-init -r -g spotify -G audio spotify + apt-get install -yqq --no-install-recommends ca-certificates wget -USER spotify +RUN wget ${URL} -O - | tar -xz && chmod +x /spotifyd -COPY --from=build /build/target/release/spotifyd /spotifyd -COPY start.sh /start.sh +FROM --platform=$TARGETPLATFORM debian:bullseye-slim -WORKDIR / +COPY --from=build /spotifyd /app/spotifyd +COPY start.sh /app/start.sh -ENTRYPOINT [ "/start.sh" ] +RUN apt-get update && \ + apt-get install -yqq --no-install-recommends ca-certificates libdbus-1-3 libasound2 && \ + useradd -r -s /bin/false spotifyd && \ + usermod -a -G audio spotifyd && \ + chown -R spotifyd:spotifyd /app + +USER spotifyd +WORKDIR /app + +ENTRYPOINT [ "/app/start.sh" ] diff --git a/README.md b/README.md index 66a15bd..96b6f02 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Spotifyd docker +# Spotifyd docker (for armv7) + +Spotifyd docker image made for the Raspberry Pi (but works on other armv7 devices too). [Repo](https://git.kapelle.org/niklas/spotifyd-docker) @@ -10,8 +12,6 @@ Run [spotifyd](https://github.com/Spotifyd/spotifyd) inside docker. Inspired by You need to add the `/dev/snd` to the container. -If the container starts successfully and you still hear no audio then the audio output may be disabled in alsa. In that case you can open bash inside your container and run `alsamixer`. There you can unmute the master. When it comes to alsa i recommend reading the [ArchWiki](https://wiki.archlinux.org/title/Advanced_Linux_Sound_Architecture) on this topic. - Check out the `docker-compose.yml` for an example. # Configuration @@ -32,4 +32,8 @@ Following variables are available. See the [spotifyd doc](https://spotifyd.githu `DEVICE_TYPE`# The displayed device type in Spotify clients. Can be `computer`, `tablet`, `smartphone`, `speaker`, `tv`, `avr`, `stb`, `audiodongle`. -`INITIAL_VOLUME` Volume on startup between 0 and 100. \ No newline at end of file +`INITIAL_VOLUME` Volume on startup between 0 and 100. + +`USE_MPRIS` Set to true to enable MPRIS support. You need to add the dbus socket to the container. Default: false. + +`EXTRA_ARGS` Additional arguments passed to spotifyd. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b175a32 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +docker buildx build --platform linux/arm/v7 . -t djeeberjr/spotifyd --push diff --git a/docker-compose.yml b/docker-compose.yml index fd9b051..40eef14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,6 @@ services: spotifyd: container_name: spotify image: djeeberjr/spotifyd - build: . devices: - "/dev/snd:/dev/snd" environment: diff --git a/start.sh b/start.sh index 88c88c3..a3d8fc8 100755 --- a/start.sh +++ b/start.sh @@ -22,4 +22,14 @@ if [ -n "$INITIAL_VOLUME" ]; then ARGS="${ARGS} --initial-volume ${INITIAL_VOLUME}" fi -./spotifyd --no-daemon --username "$USERNAME" --password "$PASSWORD" --device-name "${DEVICE:=Spotifyd}" $ARGS +# Disable mpris if not set to true +if [ -z "$USE_MPRIS" ] || [ "$USE_MPRIS" != "true" ]; then + ARGS="${ARGS} --use-mpris false" +fi + +# extra args +if [ -n "$EXTRA_ARGS" ]; then + ARGS="${ARGS} ${EXTRA_ARGS}" +fi + +/app/spotifyd --no-daemon --username "$USERNAME" --password "$PASSWORD" --device-name "${DEVICE:=Spotifyd}" $ARGS