cargo config
[source.crates-io]
replace-with = 'tuna'
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
Dockerfile
FROM ubuntu:16.04
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.64.0
RUN set -eux; \
apt-get -y update && \
apt-get -y install gcc wget llvm curl clang make cmake gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf && \
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static && \
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup && \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c' ;; \
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='48c5ecfd1409da93164af20cf4ac2c6f00688b15eb6ba65047f654060c844d85' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='e189948e396d47254103a49c987e7fb0e5dd8e34b200aa4481ecc4b8e41fb929' ;; \
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='0e0be29c560ad958ba52fcf06b3ea04435cb3cd674fbe11ce7d954093b9504fd' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
url="https://static.rust-lang.org/rustup/archive/1.25.1/${rustArch}/rustup-init"; \
wget "$url"; \
#echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version; \
rustup target add armv7-unknown-linux-gnueabihf; \
rustup target add armv7-unknown-linux-musleabihf;
WORKDIR /data/apps/hashii_chain
COPY config /usr/local/cargo
build镜像
# build_base_rust_image.sh
#!/bin/bash
docker build -t uhub.service.ucloud.cn/base/ubuntu_16.04-rust_1.64.0:v1.0 .
build 业务代码
# cat build_openethereum.sh
#!/bin/bash
docker run --rm -it -v /data/apps/hashii_chain/hashii:/data/apps/hashii_chain uhub.service.ucloud.cn/base/ubuntu_16.04-rust_1.64.0:v1.0 cargo build --release --target armv7-unknown-linux-gnueabihf