Dockerfile.Rpi 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Create a docker image for the RPI
  2. # Build the docker image from the root of the project with the following command :
  3. # $ docker build -t librespot-rpi -f .\contrib\Dockerfile.Rpi .
  4. #
  5. # This builds a docker image which is usable when running docker on the rpi.
  6. #
  7. # This Dockerfile builds in windows without any requirements, for linux based systems you might need to run the following line:
  8. # docker run --rm --privileged multiarch/qemu-user-static:register --reset
  9. # (see here for more info: https://gist.github.com/PieterScheffers/d50f609d9628383e4c9d8d7d269b7643 )
  10. #
  11. # Save the docker image to a file:
  12. # $ docker save -o contrib/librespot-rpi librespot-rpi
  13. #
  14. # Move it to the rpi and import it with:
  15. # docker load -i librespot-rpi
  16. #
  17. # Run it with:
  18. # docker run -d --restart unless-stopped $(for DEV in $(find /dev/snd -type c); do echo --device=$DEV:$DEV; done) --net=host --name librespot-rpi librespot-rpi --name {devicename}
  19. FROM debian:stretch
  20. RUN dpkg --add-architecture armhf
  21. RUN apt-get update
  22. RUN apt-get install -y curl git build-essential crossbuild-essential-armhf
  23. RUN apt-get install -y libasound2-dev libasound2-dev:armhf
  24. RUN apt-get install -y pkg-config
  25. RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
  26. ENV PATH="/root/.cargo/bin/:${PATH}"
  27. RUN rustup target add arm-unknown-linux-gnueabihf
  28. RUN mkdir /.cargo && \
  29. echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' >> /.cargo/config
  30. RUN mkdir /build
  31. ENV CARGO_TARGET_DIR /build
  32. ENV CARGO_HOME /build/cache
  33. ENV PKG_CONFIG_PATH /usr/lib/arm-linux-gnueabihf/pkgconfig/
  34. ENV PKG_CONFIG_ALLOW_CROSS 1
  35. ADD . /src
  36. WORKDIR /src
  37. RUN cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
  38. FROM resin/rpi-raspbian
  39. RUN apt-get update && \
  40. apt-get install libasound2 && \
  41. rm -rf /var/lib/apt/lists/*
  42. RUN mkdir /librespot
  43. WORKDIR /librespot
  44. COPY --from=0 /build/arm-unknown-linux-gnueabihf/release/librespot .
  45. RUN chmod +x librespot
  46. ENTRYPOINT ["./librespot"]