I want to thank all of the people who commented on my first post about this project, I can’t believe how much time has passed since I first wrote about this. I actually did get it running but ran out of time to document it all while getting it working… I planned show it at a conference for work and ran into significant hurdles along the way so my documentation slipped a bit. I’m going to finish this out thanks to the extra motivation I received from everyones interest. So let’s get to it!
- Setting up a Hyperledger Fabric development environment on a Raspberry Pi
- Building Hyperledger Fabric on Raspberry Pi
- Setting up a Docker Swarm on Raspberry Pi
- Deploying a Hyperledger Fabric network on the Swarm with Docker Stack and testing with BYFN.
Mastering the build step is a pretty decent challenge. In this article I’ll pass along some tips and hints on how I pulled it off.
Most of the content in this section is dedicated to get a working build on a Raspberry Pi. If you have no interest in doing a build yourself you can skip it and use my images. They aren’t part of the official hyperledger docker hub image set but I’ve got them out on mine for connivence. You can pull them as follows:
docker pull jmotacek/fabric-baseos:armv7l-0.3.2
docker pull jmotacek/fabric-basejvm:armv7l-0.3.2
docker pull jmotacek/fabric-baseimage:armv7l-0.3.2
docker pull jmotacek/fabric-ccenv:armv7l-1.0.7
docker pull jmotacek/fabric-javaenv:armv7l-1.0.7
docker pull jmotacek/fabric-peer:armv7l-1.0.7
docker pull jmotacek/fabric-orderer:armv7l-1.0.7
docker pull jmotacek/fabric-buildenv:armv7l-1.0.7
docker pull jmotacek/fabric-testenv:armv7l-1.0.7
docker pull jmotacek/fabric-zookeeper:armv7l-1.0.7
docker pull jmotacek/fabric-kafka:armv7l-1.0.7
docker pull jmotacek/fabric-couchdb:armv7l-1.0.7
docker pull jmotacek/fabric-tools:armv7l-1.0.7
Doing a build yourself…
First off don’t do your builds over ssh. It’s takes a while and if your tunnel is interrupted the process will fail (unless you execute the build with a special command but I won’t get into that…).
Clone the Repos
We need to get both the project and base image sources built in order.
mkdir -p go/src/github.com/hyperledger
git clone -b armv7l-0.3.2 https://github.com/Cleanshooter/fabric-baseimage.git
git clone -b release-1.0 https://github.com/hyperledger/fabric.git
I submitted a pull request to the hyperledger team because right now their base image build targets the latest version of the armv7/armhf-ubuntu docker image. However, at the time of this post, the build won’t work unless you use xenial. My repo above is a mirror of the original with the slight change to the Makefile to ensure we target the correct image. In the meantime please feel free to use my clone of their repo, I’ll try and remember to update this post if they accept the pull request (leave me a comment if you notice they accepted the pull before I do).
You might also notice that branch targets. Currently the HyperLedger team is working on V1.1 and this tutorial is for V1.0. So We need to target specific version of the repos to ensure compatibility.
Also, the official documentation says to clone from the Gerrit repo… which requires you to sign up for an LFID… which is a pain in the ass. It’s ONLY NECESSARY if you actually plan to contribute code. I’m not a Go programmer, nor do I want to be… so cloning from the Gerrit repo is unnecessary. The github repo is a “read-only” copy of the Gerrit repo and says it is updated after every commit they make. However, I’ve run into several situations where they have pull requests in gerrit or say DONE in JIRA that the changes are not reflected in the git version.
I guess you also have to sign up for an LFID if you want to join their chat. Personally the chat was hit or miss for me. In my experience 60-80% of any questions you put to the fabric channel will go unanswered. The channel is constantly littered by people asking for help setting up a non “BYFN” networks, posting error logs and only getting a response half the time, and asking for answers to questions that honestly could be found if they looked through the documentation provided. It doesn’t help that the current setup documentation really only covers one super simple use case (the BYFN). At this point in the project I think the expectation is that you will just have to figure out everything beyond the basics yourself, which means there is a really steep learning curve. Most of the time if you ask a question you just won’t get an answer. To be fair they really should have a moderator for the channel telling people to post their questions out on StackOverflow because the same questions are being asked over and over (which is probably why they are being ignored). Granted there are a few people on there that will help others when they know the answer or are online. Chat channels are nice but when a project of this complexity is open to the public and there’s little support for it… it kinda leaves you feeling more frustrated than supported.
Six months later after writing the above… It seems they are starting to use StackOverflow more which is great. I haven’t been on the rocket chat in forever but I might have to since I’m finishing this documentation.
Build the Base Images
PLEASE NOTE: The latest version (0.4.7 as of this post) of the baseimages DO NOT WORK WITH HL v1.0 anymore, if you attempt to build HL v1.0 with the latest baseimage it will fail, my experience lead me to this issue on their JIRA (which is unresolved, granted it’s just a linter failure but it looks like the GOPATH isn’t set correctly in the baseimage at the moment so I’d avoid it for safeties sake).
I did build out the v0.3.2 ones after fixing an updating some things in my own clone of the repo. This will create the amrv7l baseimages on v0.3.2 as local docker images.
Well grab your loom and prepare yourself for some serious waiting. Lets weave this fabric!
Now that we have our ARM base images and our repo cloned we can build hyperledger fabric itself. Navigate to the ~/go/src/github.com/hyperledger/fabric/ directory, which if you built your own base images is right next to it.
If you pulled the base images from my docker hub set the BASE_DOCKER_NS, ARCH and BASEIMAGE_RELEASE as I have below, otherwise remove it. If you built your own base images you can get rid of the variables.
make native docker license spelling linter unit-test BASE_DOCKER_NS=jmotacek ARCH=armv7l BASEIMAGE_RELEASE=0.3.2
The makefiles “dist-clean” command will do nothing in this environment since the project doesn’t officially support armv7l so nothing will get cleaned up. So if your build fails you’ll have to delete the release/linux-armv7l/hyperledger-fabric-linux-armv7l.$(PROJECT_VERSION).tar.gz yourself to rebuild. Personally I’ve been wiping the entire fabric directory and re-cloning the repo just to be safe.
Also, behave tests no longer work in v1.0. I suspect it’s because the build scripts pull tests directly from their repo (the latest repo which means it includes v1.1) and the new tests rely on libraries that aren’t part of the v1.0 builds (like the b3j0f.aop pip library). You may be able to add these to your development environment but the behave tests aren’t necessary, see the documentation as to why.
It’s always a hurdle to debug builds and get them working so I’m glad I’ve got some to start testing out. Our next step is setting up a docker swarm across a few of my raspberry pi’s. This step is pretty easy compared to this one so I’m hoping to have the next article in this series out soon.
If you run into any issues let me know and post a comment.