Created
November 6, 2019 11:32
-
-
Save oherrala/a2f8f8d7af1ba30ccd784c7dc62a22b6 to your computer and use it in GitHub Desktop.
Dockerfile for Rust cross compilation to aarch64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM rust:1.37.0 | |
ENV TARGET="aarch64-unknown-linux-musl" | |
ARG LIBRESSL=libressl-3.0.2 | |
ARG TOOLCHAIN_AARCH64="aarch64--musl--stable-2018.11-1" | |
ARG TC_AARCH64_URL="https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/${TOOLCHAIN_AARCH64}.tar.bz2" | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN apt -y update && \ | |
apt -y upgrade && \ | |
apt -y install \ | |
bison\ | |
flex \ | |
protobuf-compiler | |
RUN rustup target add ${TARGET} | |
COPY cargo.config "${CARGO_HOME}/config" | |
WORKDIR /opt | |
RUN curl -o- ${TC_AARCH64_URL} | tar -xjf - | |
ENV PATH="${PATH}:/opt/${TOOLCHAIN_AARCH64}/bin" | |
ENV CC_aarch64_unknown_linux_musl=aarch64-buildroot-linux-musl-gcc | |
ENV CXX_aarch64_unknown_linux_musl=aarch64-buildroot-linux-musl-g++ | |
ENV LD_aarch64_unknown_linux_musl=aarch64-buildroot-linux-musl-ld | |
WORKDIR /work | |
COPY sigs/* ./ | |
RUN gpg --no-tty --import libressl.asc | |
RUN curl -fO https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${LIBRESSL}.tar.gz && \ | |
gpg --no-tty --verify ${LIBRESSL}.tar.gz.asc ${LIBRESSL}.tar.gz && \ | |
tar zxf ${LIBRESSL}.tar.gz && \ | |
cd ${LIBRESSL} && \ | |
CC=${CC_aarch64_unknown_linux_musl} \ | |
CXX=${CXX_aarch64_unknown_linux_musl} \ | |
LD=${LD_aarch64_unknown_linux_musl} \ | |
./configure --prefix=/opt/libressl --host=aarch64-linux-musl --enable-shared=no --sysconfdir=/etc && \ | |
make V=1 -j4 && \ | |
make install | |
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR=/opt/libressl/lib | |
ENV AARCH64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR=/opt/libressl/include | |
WORKDIR / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also for
cargo.config
file: