Skip to content

Instantly share code, notes, and snippets.

@bernardoaraujor
Forked from niklasad1/Dockerfile
Last active February 28, 2022 18:40
Show Gist options
  • Save bernardoaraujor/27dceddbece1c1b73d90e7ddeb3af7e3 to your computer and use it in GitHub Desktop.
Save bernardoaraujor/27dceddbece1c1b73d90e7ddeb3af7e3 to your computer and use it in GitHub Desktop.
Polkadot Raspberry PI (64 bit) cross-compile build
#!/usr/bin/env bash
# Run this file from the root of substrate / polkadot directory.
DOCKER_IMAGE="polkadot/rpi"
docker build -t $DOCKER_IMAGE .
docker run --rm -it \
--env BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/aarch64-unknown-linux-gnu -D__ARM_PCS_VFP -mfpu=vfp -mfloat-abi=hard" \
--env CARGO_HOME=/home/rust/src/cargo_home \
-v "$(pwd)":/home/rust/src polkadot/rpi \
cargo +nightly build -Z features=itarget --target=aarch64-unknown-linux-gnu --release
# Put this file in the root of substrate / polkadot directory.
FROM rust:latest
RUN dpkg --add-architecture arm64 && \
apt-get update && apt-get upgrade -y && \
apt-get install -y aptitude && \
aptitude install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
pkg-config \
cmake \
libssl-dev \
git \
clang \
libclang-dev \
libz-dev:arm64 \
libssl-dev:arm64
RUN rustup install nightly
RUN rustup target add aarch64-unknown-linux-gnu --toolchain nightly
RUN rustup target add wasm32-unknown-unknown --toolchain nightly
RUN cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner aarch64"
ENV CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
ENV CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
ENV PKG_CONFIG_ALLOW_CROSS 1
ENV PKG_CONFIG_PATH /usr/lib/aarch64-unknown-linux-gnu/pkgconfig/
RUN useradd rust --user-group --create-home --shell /bin/bash --groups sudo
WORKDIR /home/rust/src
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment