Updated to work on a raspberry pi

This commit is contained in:
Djeeberjr 2023-08-26 23:40:56 +02:00
parent 2d918a19bc
commit 4b6be075c1
5 changed files with 40 additions and 25 deletions

View File

@ -1,26 +1,25 @@
FROM rust as build FROM --platform=$BUILDPLATFORM debian:bullseye-slim as build
WORKDIR /build 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 -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
RUN apt-get update && \ RUN apt-get update && \
apt-get install -yqq --no-install-recommends libasound2 alsa-utils && \ apt-get install -yqq --no-install-recommends ca-certificates wget
rm -rf /var/lib/apt/lists/* && \
groupadd -r spotify && \
useradd --no-log-init -r -g spotify -G audio spotify
USER spotify RUN wget ${URL} -O - | tar -xz && chmod +x /spotifyd
COPY --from=build /build/target/release/spotifyd /spotifyd FROM --platform=$TARGETPLATFORM debian:bullseye-slim
COPY start.sh /start.sh
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" ]

View File

@ -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) [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. 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. Check out the `docker-compose.yml` for an example.
# Configuration # 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`. `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. `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.

3
build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
docker buildx build --platform linux/arm/v7 . -t djeeberjr/spotifyd --push

View File

@ -4,7 +4,6 @@ services:
spotifyd: spotifyd:
container_name: spotify container_name: spotify
image: djeeberjr/spotifyd image: djeeberjr/spotifyd
build: .
devices: devices:
- "/dev/snd:/dev/snd" - "/dev/snd:/dev/snd"
environment: environment:

View File

@ -22,4 +22,14 @@ if [ -n "$INITIAL_VOLUME" ]; then
ARGS="${ARGS} --initial-volume ${INITIAL_VOLUME}" ARGS="${ARGS} --initial-volume ${INITIAL_VOLUME}"
fi 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