Dockerfile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Cross compilation environment for librespot
  2. # Build the docker image from the root of the project with the following command :
  3. # $ docker build -t librespot-cross -f contrib/Dockerfile .
  4. #
  5. # The resulting image can be used to build librespot for linux x86_64, armhf(with support for armv6hf), armel, mipsel, aarch64
  6. # $ docker run -v /tmp/librespot-build:/build librespot-cross
  7. #
  8. # The compiled binaries will be located in /tmp/librespot-build
  9. #
  10. # If only one architecture is desired, cargo can be invoked directly with the appropriate options :
  11. # $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --no-default-features --features "alsa-backend"
  12. # $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "alsa-backend"
  13. # $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "alsa-backend"
  14. # $ docker run -v /tmp/librespot-build:/build librespot-cross contrib/docker-build-pi-armv6hf.sh
  15. FROM debian:stretch
  16. RUN dpkg --add-architecture arm64
  17. RUN dpkg --add-architecture armhf
  18. RUN dpkg --add-architecture armel
  19. RUN dpkg --add-architecture mipsel
  20. RUN apt-get update
  21. RUN apt-get install -y curl git build-essential crossbuild-essential-arm64 crossbuild-essential-armel crossbuild-essential-armhf crossbuild-essential-mipsel
  22. RUN apt-get install -y libasound2-dev libasound2-dev:arm64 libasound2-dev:armel libasound2-dev:armhf libasound2-dev:mipsel
  23. RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
  24. ENV PATH="/root/.cargo/bin/:${PATH}"
  25. RUN rustup target add aarch64-unknown-linux-gnu
  26. RUN rustup target add arm-unknown-linux-gnueabi
  27. RUN rustup target add arm-unknown-linux-gnueabihf
  28. RUN rustup target add mipsel-unknown-linux-gnu
  29. RUN mkdir /.cargo && \
  30. echo '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' > /.cargo/config && \
  31. echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' >> /.cargo/config && \
  32. echo '[target.arm-unknown-linux-gnueabi]\nlinker = "arm-linux-gnueabi-gcc"' >> /.cargo/config && \
  33. echo '[target.mipsel-unknown-linux-gnu]\nlinker = "mipsel-linux-gnu-gcc"' >> /.cargo/config
  34. RUN mkdir /build && \
  35. mkdir /pi-tools && \
  36. curl -L https://github.com/raspberrypi/tools/archive/648a6eeb1e3c2b40af4eb34d88941ee0edeb3e9a.tar.gz | tar xz --strip-components 1 -C /pi-tools
  37. ENV CARGO_TARGET_DIR /build
  38. ENV CARGO_HOME /build/cache
  39. ADD . /src
  40. WORKDIR /src
  41. CMD ["/src/contrib/docker-build.sh"]