Skip to content

Build Locally

Frank V. Castellucci edited this page Mar 21, 2018 · 8 revisions

Prerequisites

We use docker images for development so the definitions below assume Docker and Docker Compose have been installed.

Clone the sawtooth-core and hashblock-exchange repos:

$ git clone https://github.com/hyperledger/sawtooth-core.git
$ git clone https://github.com/hashblock/hashblock-exchange.git

Build

Build the sawtooth-core python components.

cd ~/sawtooth-core
bin/build_all -l python

Build the hashblock components.

This will build the hashblock administrative shell and the hashblock TP family images. The build will also generate python protobuf files.

cd ~/hashblock-exchange
bin/build_all

You many need to clean your docker containers and images to build all. Add the following to your ~/.bash_aliases file and then run the dcclean and the diclean commands aliases.

alias diclean='docker images -a | grep '\'' [months|days|weeks]* ago'\'' | awk  '\''{print $3}'\'' | xargs docker rmi -f'
alias dclean='docker ps -a | grep -v '\''CONTAINER\|_config\|_data\|_run'\'' | cut -c-12 | xargs docker rm'

Docker for Windows (D4W) and Windows Subsystem for Linux (WSL)

WSL and D4w do not agree on the path structure. WSL ads /mnt to a folder path (e.g. /mnt/c) and D4W only understand folders that start with / e.g. /c. Add the following to your ~/.bashrc file to fix this problem. You do need to provide your password.

export DOCKER_HOST='tcp://0.0.0.0:2375'
export PATH=$PATH:~/bin

# mount /mnt/c to /c if not already done
if [ ! -d "/c" ] || [ ! "$(ls -A /c)" ]; then
  echo "Requiring root password to $(tput setaf 6)mount --bind /mnt/c /c$(tput sgr 0)"
  sudo mkdir -p /c
  sudo mount --bind /mnt/c /c
fi

# Change from /mnt/c/... to /c/...
if [ "$(pwd | cut -c -7)" == "/mnt/c/" ]; then
  cd "$(pwd | cut -c 5-)"
fi

# Provide docker for bash and docker-compose
docker() {
  docker.exe "$@"
}

## Run Locally

```bash
cd hashblock-exchange
docker-compose -f docker/compose/hashblock-local.yaml up

Subsequent executions will not take as long to initialize unless you change the underlying docker files.

Any of the running components can be shelled into:

docker exec -it [component name here] bash
root@2fd6faa664fc:/path#

To stop the processing, exit out of any shelled images, return to the composition terminal window and type Ctrl+C. When the shutdown completes clean up the docker-compose artifacts

; To stop the processing type Ctrl+C in the shell you started it from. 
; When the shutdown completes clean up the docker-compose artifacts

docker-compose -f docker/compose/hashblock-local.yaml down
Clone this wiki locally