Skip to content

Hyperledger Fabric developer setup

Ivan Vankov edited this page Mar 9, 2017 · 2 revisions

This tutorial shows how to setup Hyperledger Fabric using Vagrant. For more detailed explanation refer to official Fabric documentation

Steps below assume that you are using Linux, but if you adapt paths it will work for any OS

Requirements

Checkout source code

go get -u github.com/hyperledger/fabric

go get -u github.com/hyperledger/fabric-ca

Note: you can checkout fabric and fabric-ca using Git outside $GOPATH. If you do it we recommend to checkout them in the same folder, for example ~/hyperledger, so inside ~/hyperledger there are 2 folders - ~/hyperledger/fabric and ~/hyperledger/fabric-ca.

Startup Vagrant and build containers

CD to $GOPATH/src/github.com/hyperledger/fabric/devenv and execute vagrant up. This will start a new virtual machine and will install all needed tools in it.

After Vagrant boots up execute vagrant ssh. This will create SSH session inside Vagrant.

Note: depending on the OS that you are using and OS system settings vagrant ssh may not work. Use SSH client like putty to login inside Vagrant virtual machine.

Inside VM cd to /opt/gopath/src/github.com/hyperledger/fabric if you are not already there.

Inside VM execute make dist-clean all. This will build all docker containers and will run tests. This process may take some time. Be patient!

Note: Tests may take a long time to run, you can skip them. Some tests may fail - ignore them for now.

Inside VM cd to /opt/gopath/src/github.com/hyperledger/fabric-ca. If this path does not exist make sure that fabric-ca is in the same folder where fabric folder is!

Inside VM execute make docker. This will create fabric-ca docker container.

Running containers

From your host machine (not VM) execute go get -u github.com/CognitionFoundry/gohfc. Also you can make a normal Git checkout of Gohfc repository.

From your host machine (not VM) copy docker-compose.yml located in $GOPATH/src/github.com/CognitionFoundry/gohfc/examples folder to $GOPATH/src/github.com/hyperledger/fabric/. This will make file available inside Vagrant VM.

You can transfer this file inside VM in many different ways - putting it inside a shared host folder is just a simple option.

From Vagrant VM cd to folder where docker-compose.yml is located (/opt/gopath/src/github.com/hyperledger/fabric) and execute docker-compose up

Congratulations, you have running fabric-ca, peer and orderer containers. You can start using Gohfc!

Feel free to customize docker-compose.yml to suit your needs.