Build Hyperledger Fabric from Source Code

Q

How to Build Hyplerledger Fabric from source code on Ubuntu?

✍: FYIcenter.com

A

You can follow this tutorial to Build Hyplerledger Fabric binary code from source code on Ubuntu.

$ export GOPATH=$HOME/go
$ cd $GOPATH/src/github.com/hyperledger/fabric
$ make dist-clean all

...You can take a coffee break, because it may take some time...
...

Sending build context to Docker daemon  191.2MB
Step 1/24 : ARG GO_VER
Step 2/24 : ARG ALPINE_VER
Step 3/24 : FROM alpine:${ALPINE_VER} as base
...
Step 24/24 : CMD ["peer","node","start"]
 ---> Running in 60b44482054d
Removing intermediate container 60b44482054d
 ---> 8f3fb50f79a6
Successfully built 8f3fb50f79a6
Successfully tagged hyperledger/fabric-peer:latest

Sending build context to Docker daemon  191.2MB
Step 1/21 : ARG GO_VER
Step 2/21 : ARG ALPINE_VER
Step 3/21 : FROM alpine:${ALPINE_VER} as base
...
Binary available as .build/bin/orderer
...
...
Step 21/21 : CMD ["orderer"]
 ---> Running in 062c5a40777f
Removing intermediate container 062c5a40777f
 ---> 286e95994dbd
Successfully built 286e95994dbd
Successfully tagged hyperledger/fabric-orderer:latest

Sending build context to Docker daemon  3.072kB
Step 1/6 : ARG GO_VER
Step 2/6 : ARG ALPINE_VER
Step 3/6 : FROM alpine:${ALPINE_VER} as base
...
Step 6/6 : USER chaincode
 ---> Using cache
 ---> 74f2c3d2a2df
Successfully built 74f2c3d2a2df
Successfully tagged hyperledger/fabric-baseos:latest

Sending build context to Docker daemon  191.2MB
Step 1/14 : ARG GO_VER
Step 2/14 : ARG ALPINE_VER
Step 3/14 : FROM golang:${GO_VER}-alpine${ALPINE_VER} as shim
...
Step 14/14 : USER chaincode
 ---> Running in d9a15e7e44f5
Removing intermediate container d9a15e7e44f5
 ---> 6e002b790015
Successfully built 6e002b790015
Successfully tagged hyperledger/fabric-ccenv:latest

Sending build context to Docker daemon  191.2MB
Step 1/12 : ARG GO_VER
Step 2/12 : ARG ALPINE_VER
Step 3/12 : FROM golang:${GO_VER}-alpine${ALPINE_VER} as golang
...
Step 12/12 : ENV GOCACHE "/tmp"
 ---> Running in d60a6640292a
Removing intermediate container d60a6640292a
 ---> a697f522f35b
Successfully built a697f522f35b
Successfully tagged hyperledger/fabric-buildenv:latest

Sending build context to Docker daemon  191.2MB
Step 1/15 : ARG GO_VER
Step 2/15 : ARG ALPINE_VER
Step 3/15 : FROM golang:${GO_VER}-alpine as golang
...
Step 15/15 : COPY --from=tools /go/src/github.com/hyperledger/fabric/sampleconfig ${FABRIC_CFG_PATH}
 ---> 76000dad6b8e
Successfully built 76000dad6b8e
Successfully tagged hyperledger/fabric-tools:latest

All files are excluded from having license headers
Checking changed go files for spelling errors ...
xargs: misspell: No such file or directory
spell checker passed
Checking trailing spaces ...
DEP: Checking for dependency issues..
dep:
 version     : v0.5.1
 build date  : 2019-04-06
 git hash    :
 go version  : go1.11.5
 go compiler : gc
 platform    : linux/amd64
 features    : ImportDuringSolve=false
# out of sync, but ignored, due to noverify in Gopkg.toml:
github.com/grpc-ecosystem/go-grpc-middleware: 
   hash of vendored tree not equal to digest in Gopkg.lock
   
LINT: Running code checks..
Checking with gofmt
Checking with goimports
Checking for golang.org/x/net/context
Checking with go vet
METRICS: Checking for outdated reference documentation..
docker pull hyperledger/fabric-couchdb:amd64-0.4.15
amd64-0.4.15: Pulling from hyperledger/fabric-couchdb
34667c7e4631: Pull complete
52cbd2253fea: Pull complete
...
aeea025ecc4e: Pull complete

ok      github.com/hyperledger/fabric/gossip/api        0.017s  coverage: 100.0% of statements
ok      github.com/hyperledger/fabric/gossip/comm       33.898s coverage: 89.8% of statements
...
ok      github.com/hyperledger/fabric/bccsp     0.095s  coverage: 68.2% of statements
# github.com/hyperledger/fabric/vendor/github.com/miekg/pkcs11
vendor/github.com/miekg/pkcs11/pkcs11.go:28:10: fatal error: ltdl.h: No such file or directory
 #include <ltdl.h>
          ^~~~~~~~
compilation terminated.
FAIL    github.com/hyperledger/fabric/bccsp/factory [build failed]

...
ok      github.com/hyperledger/fabric/cmd/common/signer 0.227s  coverage: 93.8% of statements
Makefile:193: recipe for target 'unit-test' failed
make: *** [unit-test] Error 2

Looks good, except some unit tests failed. If you don't want to spend time to fix these compilation issues, you can install Hyperledger Fabric binary package directly.

 

⇒ Install Hyperledger Fabric Binary Package

⇐ Download Hyperledger Fabric Source Code

⇑ Hyplerledger Fabric Environment on Ubuntu

⇑⇑ Hyperledger Tutorials

2020-11-11, 1431👍, 0💬