Skip to content

Commit a9fd52b

Browse files
committedApr 8, 2018
FAB-9211 add fabric-samples to bootstrap.sh
add fabric-samples clone to bootstrap.sh checkout appropriate version tag adapt docs to changes rename samples.rst to install.rst address some localized line-wrap issues Change-Id: I121730e215340f7b675955557621909b388cfa91 Signed-off-by: Christopher Ferris <chrisfer@us.ibm.com>
1 parent c52d2d1 commit a9fd52b

7 files changed

+148
-121
lines changed
 

‎docs/source/build_network.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ you have all the :doc:`prereqs` installed on the platform(s)
2020
on which you'll be developing blockchain applications and/or operating
2121
Hyperledger Fabric.
2222

23-
You will also need to download and install the :doc:`samples`. You will notice
23+
You will also need to :doc:`install`. You will notice
2424
that there are a number of samples included in the ``fabric-samples``
2525
repository. We will be using the ``first-network`` sample. Let's open that
2626
sub-directory now.

‎docs/source/chaincode4ade.rst

+1-34
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ of compiling chaincode and driving calls.
402402
Install Hyperledger Fabric Samples
403403
----------------------------------
404404

405-
If you haven't already done so, please install the :doc:`samples`.
405+
If you haven't already done so, please :doc:`install`.
406406

407407
Navigate to the ``chaincode-docker-devmode`` directory of the ``fabric-samples``
408408
clone:
@@ -411,39 +411,6 @@ clone:
411411
412412
cd chaincode-docker-devmode
413413
414-
Download Docker images
415-
----------------------
416-
417-
We need four Docker images in order for "dev mode" to run against the supplied
418-
docker compose script. If you installed the ``fabric-samples`` repo clone and
419-
followed the instructions to :ref:`binaries`, then
420-
you should have the necessary Docker images installed locally.
421-
422-
.. note:: If you choose to manually pull the images then you must retag them as
423-
``latest``.
424-
425-
Issue a ``docker images`` command to reveal your local Docker Registry. You
426-
should see something similar to following:
427-
428-
.. code:: bash
429-
430-
docker images
431-
REPOSITORY TAG IMAGE ID CREATED SIZE
432-
hyperledger/fabric-tools latest b7bfddf508bc About an hour ago 1.46GB
433-
hyperledger/fabric-tools x86_64-1.1.0 b7bfddf508bc About an hour ago 1.46GB
434-
hyperledger/fabric-orderer latest ce0c810df36a About an hour ago 180MB
435-
hyperledger/fabric-orderer x86_64-1.1.0 ce0c810df36a About an hour ago 180MB
436-
hyperledger/fabric-peer latest b023f9be0771 About an hour ago 187MB
437-
hyperledger/fabric-peer x86_64-1.1.0 b023f9be0771 About an hour ago 187MB
438-
hyperledger/fabric-javaenv latest 82098abb1a17 About an hour ago 1.52GB
439-
hyperledger/fabric-javaenv x86_64-1.1.0 82098abb1a17 About an hour ago 1.52GB
440-
hyperledger/fabric-ccenv latest c8b4909d8d46 About an hour ago 1.39GB
441-
hyperledger/fabric-ccenv x86_64-1.1.0 c8b4909d8d46 About an hour ago 1.39GB
442-
443-
.. note:: If you retrieved the images through the :ref:`binaries`,
444-
then you will see additional images listed. However, we are only concerned with
445-
these four.
446-
447414
Now open three terminals and navigate to your ``chaincode-docker-devmode``
448415
directory in each.
449416

‎docs/source/channel_update_tutorial.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ Adding an Org to a Channel
22
==========================
33

44
.. note:: Ensure that you have downloaded the appropriate images and binaries
5-
as outlined in :doc:`samples` and :doc:`prereqs` that conform to the
5+
as outlined in :doc:`install` and :doc:`prereqs` that conform to the
66
version of this documentation (which can be found at the bottom of the
77
table of contents to the left). In particular, your version of the
8-
``fabric-samples`` folder must include the ``eyfn.sh`` ("Extending Your
9-
First Network") script and its related scripts.
8+
``fabric-samples`` folder must include the ``eyfn.sh`` ("Extending
9+
Your First Network") script and its related scripts.
1010

1111
This tutorial serves as an extension to the :doc:`build_network` (BYFN) tutorial,
1212
and will demonstrate the addition of a new organization -- ``Org3`` -- to the

‎docs/source/getting_started.rst

+6-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Getting Started
55
:maxdepth: 1
66

77
prereqs
8-
samples
8+
install
99

1010
Install Prerequisites
1111
^^^^^^^^^^^^^^^^^^^^^
@@ -15,19 +15,13 @@ you have all the :doc:`prereqs` installed on the platform(s)
1515
on which you'll be developing blockchain applications and/or operating
1616
Hyperledger Fabric.
1717

18-
Install Binaries and Docker Images
19-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
Install Samples, Binaries and Docker Images
19+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
While we work on developing real installers for the Hyperledger Fabric
22-
binaries, we provide a script that will :ref:`binaries` to your system.
23-
The script also will download the Docker images to your local registry.
24-
25-
Hyperledger Fabric Samples
26-
^^^^^^^^^^^^^^^^^^^^^^^^^^
27-
28-
We offer a set of sample applications that you may wish to install these
29-
:doc:`samples` before starting with the tutorials as the tutorials leverage
30-
the sample code.
22+
binaries, we provide a script that will :doc:`install` to your system. We think
23+
that you'll find the sample applications installed useful to learn more about
24+
the capabilities and operations of Hyperledger Fabric.
3125

3226
API Documentation
3327
^^^^^^^^^^^^^^^^^

‎docs/source/samples.rst ‎docs/source/install.rst

+11-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Hyperledger Fabric Samples
2-
==========================
1+
Install Samples, Binaries and Images
2+
====================================
33

44
.. note:: If you are running on **Windows** you will want to make use of the
55
Docker Quickstart Terminal for the upcoming terminal commands.
@@ -20,32 +20,17 @@ Hyperledger Fabric Samples
2020
and use a location under one of the shared drives.
2121

2222
Determine a location on your machine where you want to place the Hyperledger
23-
Fabric samples applications repository and open that in a terminal window. Then,
24-
execute the following commands:
23+
Fabric Samples repository and enter that directory in a terminal window. The
24+
command that follows will perform the following steps:
2525

26-
.. code:: bash
27-
28-
git clone -b master https://github.com/hyperledger/fabric-samples.git
29-
cd fabric-samples
30-
git checkout {TAG} 
31-
32-
.. note:: To ensure the samples are compatible with the version of Fabric binaries you download below,
33-
checkout the samples ``{TAG}`` that matches your Fabric version, for example, v1.1.0.
34-
To see a list of all fabric-samples tags, use command "git tag".
35-
36-
.. _binaries:
37-
38-
Download Platform-specific Binaries
39-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40-
41-
Next, we will install the Hyperledger Fabric platform-specific binaries.
42-
This process was designed to complement the Hyperledger Fabric Samples
43-
above, but can be used independently. If you are not installing the
44-
samples above, then simply create and enter a directory into which to
45-
extract the contents of the platform-specific binaries.
26+
#. if needed, clone the hyperledger/fabric-samples repository
27+
#. checkout the appropriate version tag
28+
#. install the Hyperledger Fabric platform-specific binaries and config files
29+
for the version specified into the root of the fabric-samples repository
30+
#. download the Hyperledger Fabric docker images for the version specified
4631

47-
Please execute the following command from within the directory into which
48-
you will extract the platform-specific binaries:
32+
Once you are ready, and in the directory into which you will install the
33+
Fabric Samples and binaries, go ahead and execute the following command:
4934

5035
.. code:: bash
5136

‎docs/source/write_first_app.rst

+24-19
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ If you don't have a development environment and the accompanying artifacts for
4949
the network and applications, visit the :doc:`prereqs` page and ensure you have
5050
the necessary dependencies installed on your machine.
5151

52-
Next, visit the :doc:`samples` page and follow the provided instructions. Return to
53-
this tutorial once you have cloned the ``fabric-samples`` repository, and downloaded
54-
the latest stable Fabric images and available utilities.
52+
Next, if you haven't done so already, visit the :doc:`install` page and follow
53+
the provided instructions. Return to this tutorial once you have cloned the
54+
``fabric-samples`` repository, and downloaded the latest stable Fabric images
55+
and available utilities.
5556

56-
At this point everything should be installed. Navigate to the ``fabcar`` subdirectory
57-
within your ``fabric-samples`` repository and take a look at what's inside:
57+
At this point everything should be installed. Navigate to the ``fabcar``
58+
subdirectory within your ``fabric-samples`` repository and take a look at what's
59+
inside:
5860

5961
.. code:: bash
6062
@@ -66,8 +68,8 @@ You should see the following:
6668
6769
enrollAdmin.js invoke.js package.json query.js registerUser.js startFabric.sh
6870
69-
Before starting we also need to do a little housekeeping. Run the following command to
70-
kill any stale or active containers:
71+
Before starting we also need to do a little housekeeping. Run the following
72+
command to kill any stale or active containers:
7173

7274
.. code:: bash
7375
@@ -81,9 +83,10 @@ Clear any cached networks:
8183
8284
docker network prune
8385
84-
And lastly if you've already run through this tutorial, you'll also want to delete the
85-
underlying chaincode image for the ``fabcar`` smart contract. If you're a user going through
86-
this content for the first time, then you won't have this chaincode image on your system:
86+
And lastly if you've already run through this tutorial, you'll also want to
87+
delete the underlying chaincode image for the ``fabcar`` smart contract. If
88+
you're a user going through this content for the first time, then you won't
89+
have this chaincode image on your system:
8790

8891
.. code:: bash
8992
@@ -92,22 +95,24 @@ this content for the first time, then you won't have this chaincode image on you
9295
Install the clients & launch the network
9396
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9497

95-
.. note:: The following instructions require you to be in the ``fabcar`` subdirectory
96-
within your local clone of the ``fabric-samples`` repo. Remain at the
97-
root of this subdirectory for the remainder of this tutorial.
98+
.. note:: The following instructions require you to be in the ``fabcar``
99+
subdirectory within your local clone of the ``fabric-samples`` repo.
100+
Remain at the root of this subdirectory for the remainder of this
101+
tutorial.
98102

99-
Run the following command to install the Fabric dependencies for the applications.
100-
We are concerned with ``fabric-ca-client`` which will allow our app(s) to communicate
101-
with the CA server and retrieve identity material, and with ``fabric-client`` which
102-
allows us to load the identity material and talk to the peers and ordering service.
103+
Run the following command to install the Fabric dependencies for the
104+
applications. We are concerned with ``fabric-ca-client`` which will allow our
105+
app(s) to communicate with the CA server and retrieve identity material, and
106+
with ``fabric-client`` which allows us to load the identity material and talk
107+
to the peers and ordering service.
103108

104109
.. code:: bash
105110
106111
npm install
107112
108113
Launch your network using the ``startFabric.sh`` shell script. This command
109-
will spin up our various Fabric entities and launch a smart contract container for
110-
chaincode written in Golang:
114+
will spin up our various Fabric entities and launch a smart contract container
115+
for chaincode written in Golang:
111116

112117
.. code:: bash
113118

‎scripts/bootstrap.sh

+102-26
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,26 @@
66
#
77

88
# if version not passed in, default to latest released version
9-
export VERSION=${1:-1.1.0}
9+
export VERSION=1.1.0
1010
# if ca version not passed in, default to latest released version
11-
export CA_VERSION=${2:-$VERSION}
11+
export CA_VERSION=$VERSION
1212
# current version of thirdparty images (couchdb, kafka and zookeeper) released
1313
export THIRDPARTY_IMAGE_VERSION=0.4.6
1414
export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
1515
#Set MARCH variable i.e ppc64le,s390x,x86_64,i386
1616
MARCH=`uname -m`
1717

18+
printHelp() {
19+
echo "Usage: bootstrap.sh [<version>] [<ca_version>] [-d -s -b]"
20+
echo
21+
echo "-d - bypass docker image download"
22+
echo "-s - bypass fabric-samples repo clone"
23+
echo "-b - bypass download of platform-specific binaries"
24+
echo
25+
echo "e.g. bootstrap.sh 1.1.1 -s"
26+
echo "would download docker images and binaries for version 1.1.1"
27+
}
28+
1829
dockerFabricPull() {
1930
local FABRIC_TAG=$1
2031
for IMAGES in peer orderer ccenv javaenv tools; do
@@ -47,36 +58,101 @@ dockerCaPull() {
4758
: ${FABRIC_TAG:="$MARCH-$VERSION"}
4859
: ${THIRDPARTY_TAG:="$MARCH-$THIRDPARTY_IMAGE_VERSION"}
4960

50-
echo "===> Downloading platform specific fabric binaries"
51-
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz
61+
samplesInstall() {
62+
# clone (if needed) hyperledger/fabric-samples and checkout corresponding
63+
# version to the binaries and docker images to be downloaded
64+
if [ -d first-network ]; then
65+
# if we are in the fabric-samples repo, checkout corresponding version
66+
echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples"
67+
git checkout v${VERSION}
68+
elif [ -d fabric-samples ]; then
69+
# if fabric-samples repo already cloned and in current directory,
70+
# cd fabric-samples and checkout corresponding version
71+
echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples"
72+
cd fabric-samples && git checkout v${VERSION}
73+
else
74+
echo "===> Cloning hyperledger/fabric-samples repo and checkout v${VERSION}"
75+
git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples && git checkout v${VERSION}
76+
fi
77+
}
78+
79+
binariesInstall() {
80+
echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries"
81+
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz
5282

53-
echo "===> Downloading platform specific fabric-ca-client binary"
54-
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${VERSION}/hyperledger-fabric-ca-${ARCH}-${VERSION}.tar.gz | tar xz
55-
if [ $? != 0 ]; then
83+
echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary"
84+
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${VERSION}/hyperledger-fabric-ca-${ARCH}-${VERSION}.tar.gz | tar xz
85+
if [ $? != 0 ]; then
5686
echo
57-
echo "------> $VERSION fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----"
87+
echo "------> ${CA_TAG} fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----"
5888
echo
59-
fi
60-
61-
which docker >& /dev/null
62-
NODOCKER=$?
89+
fi
90+
}
6391

64-
if [ "${NODOCKER}" == 0 ]; then
92+
dockerInstall() {
93+
which docker >& /dev/null
94+
NODOCKER=$?
95+
if [ "${NODOCKER}" == 0 ]; then
96+
echo "===> Pulling fabric Images"
97+
dockerFabricPull ${FABRIC_TAG}
98+
echo "===> Pulling fabric ca Image"
99+
dockerCaPull ${CA_TAG}
100+
echo "===> Pulling thirdparty docker images"
101+
dockerThirdPartyImagesPull ${THIRDPARTY_TAG}
102+
echo
103+
echo "===> List out hyperledger docker images"
104+
docker images | grep hyperledger*
105+
else
106+
echo "========================================================="
107+
echo "Docker not installed, bypassing download of Fabric images"
108+
echo "========================================================="
109+
fi
110+
}
65111

66-
echo "===> Pulling fabric Images"
67-
dockerFabricPull ${FABRIC_TAG}
112+
DOCKER=true
113+
SAMPLES=true
114+
BINARIES=true
68115

69-
echo "===> Pulling fabric ca Image"
70-
dockerCaPull ${CA_TAG}
116+
# Parse commandline args pull out
117+
# version and/or ca-version strings first
118+
if echo $1 | grep -q '\d'; then
119+
VERSION=$1;shift
120+
if echo $1 | grep -q '\d'; then
121+
CA_VERSION=$1;shift
122+
fi
123+
fi
71124

72-
echo "===> Pulling thirdparty docker images"
73-
dockerThirdPartyImagesPull ${THIRDPARTY_TAG}
74-
echo
125+
# then parse opts
126+
while getopts "h?dsb" opt; do
127+
case "$opt" in
128+
h|\?)
129+
printHelp
130+
exit 0
131+
;;
132+
d) DOCKER=false
133+
;;
134+
s) SAMPLES=false
135+
;;
136+
b) BINARIES=false
137+
;;
138+
esac
139+
done
75140

76-
echo "===> List out hyperledger docker images"
77-
docker images | grep hyperledger*
78-
else
79-
echo "========================================================="
80-
echo "Docker not installed, bypassing download of Fabric images"
81-
echo "========================================================="
141+
if [ "$SAMPLES" == "true" ]; then
142+
echo
143+
echo "Installing hyperledger/fabric-samples repo"
144+
echo
145+
samplesInstall
146+
fi
147+
if [ "$BINARIES" == "true" ]; then
148+
echo
149+
echo "Installing Hyperledger Fabric binaries"
150+
echo
151+
binariesInstall
152+
fi
153+
if [ "$DOCKER" == "true" ]; then
154+
echo
155+
echo "Installing Hyperledger Fabric docker images"
156+
echo
157+
dockerInstall
82158
fi

0 commit comments

Comments
 (0)