FROM stacks-blockchain:2.1-stretch as stacks-node

FROM rust:bullseye AS test

WORKDIR /build

RUN rustup component add llvm-tools-preview && \
    cargo install grcov

ENV RUSTFLAGS="-Cinstrument-coverage" \
    LLVM_PROFILE_FILE="stacks-blockchain-%p-%m.profraw" \
    STACKS_NODE_TEST="1"

COPY --from=stacks-node /bin/stacks-node /bin/

COPY . .

RUN cargo build --workspace && \
    cargo test --workspace --bin=subnet-node --no-run

