commit 54b88801a1a379d705029bdde80b1226483f433d Author: Paul van Tilburg Date: Sun Jan 1 13:08:11 2023 +0100 Initial import into git diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..a993a65 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,18 @@ +FROM docker.io/rust:bullseye + +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross +# Uncomment if you need to add more build dependencies to the image: +# RUN apt-get install -y + +RUN rustup target add armv7-unknown-linux-gnueabihf +RUN rustup toolchain install stable-armv7-unknown-linux-gnueabihf +RUN cargo install cargo-deb + +WORKDIR /app + +ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ + CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ + CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ + +CMD ["cargo", "deb", "--target", "armv7-unknown-linux-gnueabihf"] diff --git a/Dockerfile.armhf b/Dockerfile.armhf new file mode 100644 index 0000000..11d86c3 --- /dev/null +++ b/Dockerfile.armhf @@ -0,0 +1,18 @@ +FROM docker.io/rust:bullseye + +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross +# Uncomment if you need to add more build dependencies to the image: +# RUN apt-get install -y + +RUN rustup target add aarch64-unknown-linux-gnu +RUN rustup toolchain install stable-aarch64-unknown-linux-gnu +RUN cargo install cargo-deb + +WORKDIR /app + +ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ + CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ + +CMD ["cargo", "deb", "--target", "aarch64-unknown-linux-gnu"] diff --git a/Dockerfile.i686 b/Dockerfile.i686 new file mode 100644 index 0000000..41c895b --- /dev/null +++ b/Dockerfile.i686 @@ -0,0 +1,11 @@ +FROM docker.io/rust:bullseye + +RUN apt-get update && apt-get upgrade -y +# Uncomment if you need to add more build dependencies to the image: +# RUN apt-get install -y + +RUN cargo install cargo-deb + +WORKDIR /app + +CMD ["cargo", "deb"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..b9784e5 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +# Docker files for cross-builds using cargo-deb + +These files allows you to build Debian packages for the (Debian) architectures +i686, armhf and arm64 using an amd64 system. + +Note that the `Dockerfile`s use the full Rust Debian Buster Docker image and +not the slim version so that some common build-dependencies (such as +`libssl-dev`) are already present. + +## Cross-compile to i686 + +Build the image: + +```console +$ docker build . -t cargo-deb-crossbuild/i686 --platform linux/386 -f Dockerfile +STEP 1/5: FROM docker.io/rust:bullseye +Trying to pull docker.io/library/rust:bullseye... +Getting image source signatures +... +``` + +In your Rust project, run: + +```console +$ docker run --rm -ti -v `pwd`:/app cargo-deb-crossbuild/i686 +... +/app/target/debian/.deb +``` + +You can find the resulting deb file in `./target/debian`. + +## Cross-compile to arm64 (ARM v8) + +Build the image: + +```console +$ docker build . -t cargo-deb-crossbuild/arm64 --platform linux/arm64/v8 -f Dockerfile +STEP 1/5: FROM docker.io/rust:bullseye +Trying to pull docker.io/library/rust:bullseye... +Getting image source signatures +... +``` + +In your Rust project, run: + +```console +$ docker run --rm -ti -v `pwd`:/app cargo-deb-crossbuild/arm64 +... +/app/target/debian/.deb +``` + +You can find the resulting deb file in `./target/debian`. + +## Cross-compile to armhf (ARM v7) + +Build the image: + +```console +$ docker build . -t cargo-deb-crossbuild/armhf --platform linux/arm/v7 -f Dockerfile +STEP 1/5: FROM docker.io/rust:bullseye +Trying to pull docker.io/library/rust:bullseye... +Getting image source signatures +... +``` + +In your Rust project, run: + +```console +$ docker run --rm -ti -v `pwd`:/app cargo-deb-crossbuild/armhf +... +/app/target/debian/.deb +``` + +You can find the resulting deb file in `./target/debian`.