Skip to content

Build Locally

Frank V. Castellucci edited this page May 12, 2018 · 8 revisions

Prerequisites

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

hashblock-exchange

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

hyperledger sawtooth components

These will be automatically installed when you compose up hashblock

Batteries not needed

The hashblock-exchange repos comes equipped with all the goodies to run and observe behavior locally. This includes transaction authorizations, voting keys configurations, a ready to rock genesis.batch file for the sawtooth-validator and even a simple data seeder file to get you rolling.

Build

If you are a Windows user, see the note at the bottom of the page before continuing.

Build the hashblock administrative, REST and hashblock TP family docker images. The build will also generates the necessary python protobuf files. To begin, change to the root of the hashblock-exchange directory on your machine and:

$ bin/build_all

Run Locally

Starting hashblock-exchange

While still in the hashblock-exchange root folder:

$ docker-compose -f docker/compose/hashblock-local.yaml up

As noted, the first execution may take a bit to start up due to the download of the hyperledger/sawtooth services. Subsequent executions will not take as long to initialize unless you change the underlying docker files.

Peruse any container

Once running, any of the running containers (hashblock or sawtooth) can be shelled into:

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

Stopping hashblock-exchange

To stop the hashblock-exchange 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 window you started it from.
; When the shutdown completes clean up the docker containers

docker-compose -f docker/compose/hashblock-local.yaml down

Windows

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 "$@"
}