FROM alpine:3.20 AS rust-builder RUN apk add wget ARG TARGETPLATFORM ENV RUST_VERSION=1.82 RUN case "${TARGETPLATFORM}" in \ "linux/amd64") \ echo 'export RUST_TARGET="x86_64-unknown-linux-musl"' > ./.env ;; \ "linux/arm64") \ echo 'export RUST_TARGET="aarch64-unknown-linux-musl"' > ./.env ;; \ *) \ exit 239 ;; \ esac RUN source ./.env && \ wget https://static.rust-lang.org/rustup/dist/${RUST_TARGET}/rustup-init && \ chmod +x rustup-init && \ ./rustup-init -y --default-toolchain=${RUST_VERSION} --default-host=${RUST_TARGET} ENV PATH=/root/.cargo/bin:$PATH ENV LIBUNWIND_VERSION=1.8.1 RUN apk add make gcc musl-dev RUN source ./.env && \ wget https://github.com/libunwind/libunwind/releases/download/v${LIBUNWIND_VERSION}/libunwind-${LIBUNWIND_VERSION}.tar.gz && \ tar -zxvf libunwind-${LIBUNWIND_VERSION}.tar.gz && \ cd libunwind-${LIBUNWIND_VERSION} && \ ./configure --disable-minidebuginfo --enable-ptrace --disable-tests --disable-documentation --prefix=/usr/local/musl/${RUST_TARGET} && \ make -j16 && \ make install RUN source ./.env && \ wget https://zlib.net/zlib-1.3.1.tar.gz && \ tar -zxvf zlib-1.3.1.tar.gz && \ cd zlib-1.3.1 && \ ./configure --prefix=/usr/local/musl/${RUST_TARGET} && \ make -j16 && \ make install