Dockerfile.Rpi 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 curl https://sh.rustup.rs -sSf | sh -s -- -y
  25. ENV PATH="/root/.cargo/bin/:${PATH}"
  26. RUN rustup target add arm-unknown-linux-gnueabihf
  27. RUN mkdir /.cargo && \
  28. echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' >> /.cargo/config
  29. RUN mkdir /build
  30. ENV CARGO_TARGET_DIR /build
  31. ENV CARGO_HOME /build/cache
  32. ADD . /src
  33. WORKDIR /src
  34. RUN cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
  35. FROM resin/rpi-raspbian
  36. RUN apt-get update && \
  37. apt-get install libasound2 && \
  38. rm -rf /var/lib/apt/lists/*
  39. RUN mkdir /librespot
  40. WORKDIR /librespot
  41. COPY --from=0 /build/arm-unknown-linux-gnueabihf/release/librespot .
  42. RUN chmod +x librespot
  43. ENTRYPOINT ["./librespot"]