diff --git a/docs/source/build_network.rst b/docs/source/build_network.rst index f94344ebfee..e193000b556 100644 --- a/docs/source/build_network.rst +++ b/docs/source/build_network.rst @@ -20,7 +20,7 @@ you have all the :doc:`prereqs` installed on the platform(s) on which you'll be developing blockchain applications and/or operating Hyperledger Fabric. -You will also need to download and install the :doc:`samples`. You will notice +You will also need to :doc:`install`. You will notice that there are a number of samples included in the ``fabric-samples`` repository. We will be using the ``first-network`` sample. Let's open that sub-directory now. diff --git a/docs/source/chaincode4ade.rst b/docs/source/chaincode4ade.rst index 72d867e7f24..9b87ad09863 100644 --- a/docs/source/chaincode4ade.rst +++ b/docs/source/chaincode4ade.rst @@ -402,7 +402,7 @@ of compiling chaincode and driving calls. Install Hyperledger Fabric Samples ---------------------------------- -If you haven't already done so, please install the :doc:`samples`. +If you haven't already done so, please :doc:`install`. Navigate to the ``chaincode-docker-devmode`` directory of the ``fabric-samples`` clone: @@ -411,39 +411,6 @@ clone: cd chaincode-docker-devmode -Download Docker images ----------------------- - -We need four Docker images in order for "dev mode" to run against the supplied -docker compose script. If you installed the ``fabric-samples`` repo clone and -followed the instructions to :ref:`binaries`, then -you should have the necessary Docker images installed locally. - -.. note:: If you choose to manually pull the images then you must retag them as - ``latest``. - -Issue a ``docker images`` command to reveal your local Docker Registry. You -should see something similar to following: - -.. code:: bash - - docker images - REPOSITORY TAG IMAGE ID CREATED SIZE - hyperledger/fabric-tools latest b7bfddf508bc About an hour ago 1.46GB - hyperledger/fabric-tools x86_64-1.1.0 b7bfddf508bc About an hour ago 1.46GB - hyperledger/fabric-orderer latest ce0c810df36a About an hour ago 180MB - hyperledger/fabric-orderer x86_64-1.1.0 ce0c810df36a About an hour ago 180MB - hyperledger/fabric-peer latest b023f9be0771 About an hour ago 187MB - hyperledger/fabric-peer x86_64-1.1.0 b023f9be0771 About an hour ago 187MB - hyperledger/fabric-javaenv latest 82098abb1a17 About an hour ago 1.52GB - hyperledger/fabric-javaenv x86_64-1.1.0 82098abb1a17 About an hour ago 1.52GB - hyperledger/fabric-ccenv latest c8b4909d8d46 About an hour ago 1.39GB - hyperledger/fabric-ccenv x86_64-1.1.0 c8b4909d8d46 About an hour ago 1.39GB - -.. note:: If you retrieved the images through the :ref:`binaries`, - then you will see additional images listed. However, we are only concerned with - these four. - Now open three terminals and navigate to your ``chaincode-docker-devmode`` directory in each. diff --git a/docs/source/channel_update_tutorial.rst b/docs/source/channel_update_tutorial.rst index 32cb842ce88..2b4e1540e30 100644 --- a/docs/source/channel_update_tutorial.rst +++ b/docs/source/channel_update_tutorial.rst @@ -2,11 +2,11 @@ Adding an Org to a Channel ========================== .. note:: Ensure that you have downloaded the appropriate images and binaries - as outlined in :doc:`samples` and :doc:`prereqs` that conform to the + as outlined in :doc:`install` and :doc:`prereqs` that conform to the version of this documentation (which can be found at the bottom of the table of contents to the left). In particular, your version of the - ``fabric-samples`` folder must include the ``eyfn.sh`` ("Extending Your - First Network") script and its related scripts. + ``fabric-samples`` folder must include the ``eyfn.sh`` ("Extending + Your First Network") script and its related scripts. This tutorial serves as an extension to the :doc:`build_network` (BYFN) tutorial, and will demonstrate the addition of a new organization -- ``Org3`` -- to the diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index dbb7eea3347..4e6fc8a967e 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -5,7 +5,7 @@ Getting Started :maxdepth: 1 prereqs - samples + install Install Prerequisites ^^^^^^^^^^^^^^^^^^^^^ @@ -15,19 +15,13 @@ you have all the :doc:`prereqs` installed on the platform(s) on which you'll be developing blockchain applications and/or operating Hyperledger Fabric. -Install Binaries and Docker Images -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Install Samples, Binaries and Docker Images +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ While we work on developing real installers for the Hyperledger Fabric -binaries, we provide a script that will :ref:`binaries` to your system. -The script also will download the Docker images to your local registry. - -Hyperledger Fabric Samples -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -We offer a set of sample applications that you may wish to install these -:doc:`samples` before starting with the tutorials as the tutorials leverage -the sample code. +binaries, we provide a script that will :doc:`install` to your system. We think +that you'll find the sample applications installed useful to learn more about +the capabilities and operations of Hyperledger Fabric. API Documentation ^^^^^^^^^^^^^^^^^ diff --git a/docs/source/samples.rst b/docs/source/install.rst similarity index 75% rename from docs/source/samples.rst rename to docs/source/install.rst index 1f8be0636c6..e55d15d87aa 100644 --- a/docs/source/samples.rst +++ b/docs/source/install.rst @@ -1,5 +1,5 @@ -Hyperledger Fabric Samples -========================== +Install Samples, Binaries and Images +==================================== .. note:: If you are running on **Windows** you will want to make use of the Docker Quickstart Terminal for the upcoming terminal commands. @@ -20,32 +20,17 @@ Hyperledger Fabric Samples and use a location under one of the shared drives. Determine a location on your machine where you want to place the Hyperledger -Fabric samples applications repository and open that in a terminal window. Then, -execute the following commands: +Fabric Samples repository and enter that directory in a terminal window. The +command that follows will perform the following steps: -.. code:: bash - - git clone -b master https://github.com/hyperledger/fabric-samples.git - cd fabric-samples - git checkout {TAG}  - -.. note:: To ensure the samples are compatible with the version of Fabric binaries you download below, - checkout the samples ``{TAG}`` that matches your Fabric version, for example, v1.1.0. - To see a list of all fabric-samples tags, use command "git tag". - -.. _binaries: - -Download Platform-specific Binaries -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Next, we will install the Hyperledger Fabric platform-specific binaries. -This process was designed to complement the Hyperledger Fabric Samples -above, but can be used independently. If you are not installing the -samples above, then simply create and enter a directory into which to -extract the contents of the platform-specific binaries. +#. if needed, clone the hyperledger/fabric-samples repository +#. checkout the appropriate version tag +#. install the Hyperledger Fabric platform-specific binaries and config files + for the version specified into the root of the fabric-samples repository +#. download the Hyperledger Fabric docker images for the version specified -Please execute the following command from within the directory into which -you will extract the platform-specific binaries: +Once you are ready, and in the directory into which you will install the +Fabric Samples and binaries, go ahead and execute the following command: .. code:: bash diff --git a/docs/source/write_first_app.rst b/docs/source/write_first_app.rst index afb59c2df95..54a4d759c80 100644 --- a/docs/source/write_first_app.rst +++ b/docs/source/write_first_app.rst @@ -49,12 +49,14 @@ If you don't have a development environment and the accompanying artifacts for the network and applications, visit the :doc:`prereqs` page and ensure you have the necessary dependencies installed on your machine. -Next, visit the :doc:`samples` page and follow the provided instructions. Return to -this tutorial once you have cloned the ``fabric-samples`` repository, and downloaded -the latest stable Fabric images and available utilities. +Next, if you haven't done so already, visit the :doc:`install` page and follow +the provided instructions. Return to this tutorial once you have cloned the +``fabric-samples`` repository, and downloaded the latest stable Fabric images +and available utilities. -At this point everything should be installed. Navigate to the ``fabcar`` subdirectory -within your ``fabric-samples`` repository and take a look at what's inside: +At this point everything should be installed. Navigate to the ``fabcar`` +subdirectory within your ``fabric-samples`` repository and take a look at what's +inside: .. code:: bash @@ -66,8 +68,8 @@ You should see the following: enrollAdmin.js invoke.js package.json query.js registerUser.js startFabric.sh -Before starting we also need to do a little housekeeping. Run the following command to -kill any stale or active containers: +Before starting we also need to do a little housekeeping. Run the following +command to kill any stale or active containers: .. code:: bash @@ -81,9 +83,10 @@ Clear any cached networks: docker network prune -And lastly if you've already run through this tutorial, you'll also want to delete the -underlying chaincode image for the ``fabcar`` smart contract. If you're a user going through -this content for the first time, then you won't have this chaincode image on your system: +And lastly if you've already run through this tutorial, you'll also want to +delete the underlying chaincode image for the ``fabcar`` smart contract. If +you're a user going through this content for the first time, then you won't +have this chaincode image on your system: .. code:: bash @@ -92,22 +95,24 @@ this content for the first time, then you won't have this chaincode image on you Install the clients & launch the network ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. note:: The following instructions require you to be in the ``fabcar`` subdirectory - within your local clone of the ``fabric-samples`` repo. Remain at the - root of this subdirectory for the remainder of this tutorial. +.. note:: The following instructions require you to be in the ``fabcar`` + subdirectory within your local clone of the ``fabric-samples`` repo. + Remain at the root of this subdirectory for the remainder of this + tutorial. -Run the following command to install the Fabric dependencies for the applications. -We are concerned with ``fabric-ca-client`` which will allow our app(s) to communicate -with the CA server and retrieve identity material, and with ``fabric-client`` which -allows us to load the identity material and talk to the peers and ordering service. +Run the following command to install the Fabric dependencies for the +applications. We are concerned with ``fabric-ca-client`` which will allow our +app(s) to communicate with the CA server and retrieve identity material, and +with ``fabric-client`` which allows us to load the identity material and talk +to the peers and ordering service. .. code:: bash npm install Launch your network using the ``startFabric.sh`` shell script. This command -will spin up our various Fabric entities and launch a smart contract container for -chaincode written in Golang: +will spin up our various Fabric entities and launch a smart contract container +for chaincode written in Golang: .. code:: bash diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 17db018372d..c84919dfd0d 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -6,15 +6,26 @@ # # if version not passed in, default to latest released version -export VERSION=${1:-1.1.0} +export VERSION=1.1.0 # if ca version not passed in, default to latest released version -export CA_VERSION=${2:-$VERSION} +export CA_VERSION=$VERSION # current version of thirdparty images (couchdb, kafka and zookeeper) released export THIRDPARTY_IMAGE_VERSION=0.4.6 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)}') #Set MARCH variable i.e ppc64le,s390x,x86_64,i386 MARCH=`uname -m` +printHelp() { + echo "Usage: bootstrap.sh [] [] [-d -s -b]" + echo + echo "-d - bypass docker image download" + echo "-s - bypass fabric-samples repo clone" + echo "-b - bypass download of platform-specific binaries" + echo + echo "e.g. bootstrap.sh 1.1.1 -s" + echo "would download docker images and binaries for version 1.1.1" +} + dockerFabricPull() { local FABRIC_TAG=$1 for IMAGES in peer orderer ccenv javaenv tools; do @@ -47,36 +58,101 @@ dockerCaPull() { : ${FABRIC_TAG:="$MARCH-$VERSION"} : ${THIRDPARTY_TAG:="$MARCH-$THIRDPARTY_IMAGE_VERSION"} -echo "===> Downloading platform specific fabric binaries" -curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz +samplesInstall() { + # clone (if needed) hyperledger/fabric-samples and checkout corresponding + # version to the binaries and docker images to be downloaded + if [ -d first-network ]; then + # if we are in the fabric-samples repo, checkout corresponding version + echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples" + git checkout v${VERSION} + elif [ -d fabric-samples ]; then + # if fabric-samples repo already cloned and in current directory, + # cd fabric-samples and checkout corresponding version + echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples" + cd fabric-samples && git checkout v${VERSION} + else + echo "===> Cloning hyperledger/fabric-samples repo and checkout v${VERSION}" + git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples && git checkout v${VERSION} + fi +} + +binariesInstall() { + echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries" + curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz -echo "===> Downloading platform specific fabric-ca-client binary" -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 -if [ $? != 0 ]; then + echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary" + 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 + if [ $? != 0 ]; then echo - echo "------> $VERSION fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----" + echo "------> ${CA_TAG} fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----" echo -fi - -which docker >& /dev/null -NODOCKER=$? + fi +} -if [ "${NODOCKER}" == 0 ]; then +dockerInstall() { + which docker >& /dev/null + NODOCKER=$? + if [ "${NODOCKER}" == 0 ]; then + echo "===> Pulling fabric Images" + dockerFabricPull ${FABRIC_TAG} + echo "===> Pulling fabric ca Image" + dockerCaPull ${CA_TAG} + echo "===> Pulling thirdparty docker images" + dockerThirdPartyImagesPull ${THIRDPARTY_TAG} + echo + echo "===> List out hyperledger docker images" + docker images | grep hyperledger* + else + echo "=========================================================" + echo "Docker not installed, bypassing download of Fabric images" + echo "=========================================================" + fi +} - echo "===> Pulling fabric Images" - dockerFabricPull ${FABRIC_TAG} +DOCKER=true +SAMPLES=true +BINARIES=true - echo "===> Pulling fabric ca Image" - dockerCaPull ${CA_TAG} +# Parse commandline args pull out +# version and/or ca-version strings first +if echo $1 | grep -q '\d'; then + VERSION=$1;shift + if echo $1 | grep -q '\d'; then + CA_VERSION=$1;shift + fi +fi - echo "===> Pulling thirdparty docker images" - dockerThirdPartyImagesPull ${THIRDPARTY_TAG} - echo +# then parse opts +while getopts "h?dsb" opt; do + case "$opt" in + h|\?) + printHelp + exit 0 + ;; + d) DOCKER=false + ;; + s) SAMPLES=false + ;; + b) BINARIES=false + ;; + esac +done - echo "===> List out hyperledger docker images" - docker images | grep hyperledger* -else - echo "=========================================================" - echo "Docker not installed, bypassing download of Fabric images" - echo "=========================================================" +if [ "$SAMPLES" == "true" ]; then + echo + echo "Installing hyperledger/fabric-samples repo" + echo + samplesInstall +fi +if [ "$BINARIES" == "true" ]; then + echo + echo "Installing Hyperledger Fabric binaries" + echo + binariesInstall +fi +if [ "$DOCKER" == "true" ]; then + echo + echo "Installing Hyperledger Fabric docker images" + echo + dockerInstall fi