Trouble compiling rust crates that include C libraries for aarch64 Trouble compiling rust crates that include C libraries for aarch64 docker docker

Trouble compiling rust crates that include C libraries for aarch64


I was able to get it working after copying the env vars in this file mentioned here

My updated Dockerfile looks like this

FROM rust as builderARG APP_NAME="app"ARG TARGET="aarch64-unknown-linux-musl"ARG GITHUB_SSH_KEY=""RUN apt-get updateRUN apt-get install clang llvm -yRUN rustup target add $TARGETRUN mkdir /usr/src/$APP_NAMEWORKDIR /usr/src/$APP_NAMEENV CARGO_NET_GIT_FETCH_WITH_CLI=trueENV CC_aarch64_unknown_linux_musl=clangENV AR_aarch64_unknown_linux_musl=llvm-arENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu"COPY Cargo.toml Cargo.lock ./COPY ./src ./srcRUN mkdir /root/.ssh/RUN echo "$GITHUB_SSH_KEY" > /root/.ssh/id_rsa;RUN chmod 400 /root/.ssh/id_rsaRUN ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hostsRUN cargo build --release --target=$TARGETRUN groupadd -g 10001 -r $APP_NAMERUN useradd -r -g $APP_NAME -u 10001 $APP_NAME# ------------------------------------------------------------------------------FROM scratchARG APP_NAME="app"ARG TARGET="aarch64-unknown-linux-musl"WORKDIR /user/local/bin/COPY --from=0 /etc/passwd /etc/passwdCOPY --from=builder /usr/src/$APP_NAME/target/$TARGET/release/$APP_NAME ./appUSER $APP_NAMECMD ["./app"]

With this set up the binary compiles and runs from the scratch container, thanks @HHK for pointing me to the open issues on this topic