This guide will help you save time building Sawtooth Core using the official development build tooling.
Prerequisites:
- You have docker installed and setup
- You have already built the docker image you are using, I use sawtooth-validator as an example, but this works with other docker containers that build Rust code
First, you want to create a persistent Docker volume where all the libraries cargo downloads will live so you don't have to re-download them over and over:
$ docker volume create cargo-registry
cargo-registry
We want to start an interactive container and mount our volume and our project on the container's file system so we can use them:
$ docker run -it \
-v $(pwd):/project/sawtooth-core \
-v cargo-registry:/root/.cargo/registry
sawtooth-vaidator-local
bash
root@cad7d4019d14:/#
You can now build your code:
$ cd /project/sawtooth-core/validator
$ cargo check # or `build` or `build --release`
NOTE: Take a look at the command directive in the Dockerfile you are starting from to know what you should be doing here. For example, with the validator package, you need to do:
$ cargo build --release \
&& cp ./target/release/sawtooth-validator bin/sawtooth-validator \
&& cp ./target/release/libsawtooth_validator.so lib/libsawtooth_validator.so