Dockerfile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 and armel.
  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 "with-syntex alsa-backend"
  12. # $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabihf --no-default-features --features "with-syntex alsa-backend"
  13. # $ docker run -v /tmp/librespot-build:/build librespot-cross cargo build --release --target arm-unknown-linux-gnueabi --no-default-features --features "with-syntex alsa-backend"
  14. #
  15. FROM debian:stretch
  16. RUN dpkg --add-architecture armhf
  17. RUN dpkg --add-architecture armel
  18. RUN apt-get update
  19. RUN apt-get install -y curl build-essential crossbuild-essential-armhf crossbuild-essential-armel
  20. RUN apt-get install -y libasound2-dev libasound2-dev:armhf libasound2-dev:armel
  21. RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
  22. ENV PATH="/root/.cargo/bin/:${PATH}"
  23. RUN rustup target add arm-unknown-linux-gnueabi
  24. RUN rustup target add arm-unknown-linux-gnueabihf
  25. RUN mkdir /.cargo && \
  26. echo '[target.arm-unknown-linux-gnueabihf]\nlinker = "arm-linux-gnueabihf-gcc"' > /.cargo/config && \
  27. echo '[target.arm-unknown-linux-gnueabi]\nlinker = "arm-linux-gnueabi-gcc"' >> /.cargo/config
  28. RUN mkdir /build
  29. ENV CARGO_TARGET_DIR /build
  30. ENV CARGO_HOME /build/cache
  31. ADD . /src
  32. WORKDIR /src
  33. CMD ["/src/contrib/docker-build.sh"]