FROM rust:1.62@sha256:5777f201f507075309c4d2d1c1e8d8219e654ae1de154c844341050016a64a0c as aptos-node

RUN apt-get update && apt-get -y install libclang-dev libudev-dev libdw-dev jq cmake curl npm gcc g++ make lld

WORKDIR /tmp

RUN git clone https://github.com/aptos-labs/aptos-core.git
WORKDIR /tmp/aptos-core

# Build aptos 2.0.3
RUN git reset --hard 6f83bc6d02207298b2dee91133d75538789bf582
RUN cargo build -p aptos --profile cli

FROM rust:1.62@sha256:5777f201f507075309c4d2d1c1e8d8219e654ae1de154c844341050016a64a0c as export-stage
COPY --from=aptos-node /tmp/aptos-core/target/cli/aptos /usr/local/cargo/bin/aptos
