FROM rust:stretch as build

ARG STACKS_NODE_VERSION="No Version Info"
ARG GIT_BRANCH='No Branch Info'
ARG GIT_COMMIT='No Commit Info'

WORKDIR /src

COPY . .

RUN rustup target add aarch64-unknown-linux-gnu

RUN apt-get update && apt-get install -y git gcc-aarch64-linux-gnu

RUN CC=aarch64-linux-gnu-gcc \
    CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
    CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
    cargo build --release --workspace --target aarch64-unknown-linux-gnu

RUN mkdir /out && cp -R /src/target/aarch64-unknown-linux-gnu/release/. /out

FROM scratch AS export-stage
COPY --from=build /out/blockstack-core /out/blockstack-cli /out/clarity-cli /out/stacks-node /