Skip to content

Instantly share code, notes, and snippets.

@niklasad1
Forked from pepyakin/Dockerfile
Last active February 28, 2022 15:15
Show Gist options
  • Save niklasad1/fa227f2fed4c1531b39683057a95779f to your computer and use it in GitHub Desktop.
Save niklasad1/fa227f2fed4c1531b39683057a95779f to your computer and use it in GitHub Desktop.
Polkadot Raspberry PI cross-compile build
#!/usr/bin/env bash
# Run this script from the directory with the Cargo project.
DOCKER_IMAGE="polkadot/rpi"
docker build -t $DOCKER_IMAGE .
docker run --rm -it \
--env BINDGEN_EXTRA_CLANG_ARGS="--sysroot=/usr/arm-linux-gnueabihf -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=armv7-unknown-linux-gnueabihf --release
# Put this file in the root of substrate / polkadot directory and build the image using
# the following command
#
# docker build -t <container id> .
#
# you can pick <container id> yourself. For example: `johndoe/rpi-cross`.
#
FROM rust:latest
RUN dpkg --add-architecture armhf && \
apt-get update && apt-get upgrade -y && \
apt-get install -y aptitude && \
aptitude install -y \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
pkg-config \
cmake \
libssl-dev \
git \
clang \
libclang-dev \
libssl-dev:armhf
RUN rustup install nightly
RUN rustup target add armv7-unknown-linux-gnueabihf --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_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER arm-linux-gnueabihf-gcc
ENV PKG_CONFIG_ALLOW_CROSS 1
ENV PKG_CONFIG_PATH /usr/lib/arm-linux-gnueabihf/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