github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/docs/source/dev-setup/devenv.rst (about)

     1  Setting up the development environment
     2  --------------------------------------
     3  
     4  Overview
     5  ~~~~~~~~
     6  
     7  Prior to the v1.0.0 release, the development environment utilized Vagrant
     8  running an Ubuntu image, which in turn launched Docker containers as a
     9  means of ensuring a consistent experience for developers who might be
    10  working with varying platforms, such as macOS, Windows, Linux, or
    11  whatever. Advances in Docker have enabled native support on the most
    12  popular development platforms: macOS and Windows. Hence, we have
    13  reworked our build to take full advantage of these advances. While we
    14  still maintain a Vagrant based approach that can be used for older
    15  versions of macOS and Windows that Docker does not support, we strongly
    16  encourage that the non-Vagrant development setup be used.
    17  
    18  Note that while the Vagrant-based development setup could not be used in
    19  a cloud context, the Docker-based build does support cloud platforms
    20  such as AWS, Azure, Google and IBM to name a few. Please follow the
    21  instructions for Ubuntu builds, below.
    22  
    23  Prerequisites
    24  ~~~~~~~~~~~~~
    25  
    26  -  `Git client <https://git-scm.com/downloads>`__
    27  -  `Go <https://golang.org/>`__ - 1.7.5
    28  -  For macOS,
    29     `Xcode <https://itunes.apple.com/us/app/xcode/id497799835?mt=12>`__
    30     must be installed
    31  -  `Docker <https://www.docker.com/products/overview>`__ - 17.03.0-ce or later
    32  -  `Docker Compose <https://docs.docker.com/compose/>`__ - 1.8.1 or later
    33  -  `Pip <https://pip.pypa.io/en/stable/installing/>`__
    34  -  (macOS) you may need to install gnutar, as macOS comes with bsdtar
    35     as the default, but the build uses some gnutar flags. You can use
    36     Homebrew to install it as follows:
    37  
    38  ::
    39  
    40      brew install gnu-tar --with-default-names
    41  
    42  -  (only if using Vagrant) - `Vagrant <https://www.vagrantup.com/>`__ -
    43     1.7.4 or later
    44  -  (only if using Vagrant) -
    45     `VirtualBox <https://www.virtualbox.org/>`__ - 5.0 or later
    46  -  BIOS Enabled Virtualization - Varies based on hardware
    47  
    48  -  Note: The BIOS Enabled Virtualization may be within the CPU or
    49     Security settings of the BIOS
    50  
    51  ``pip``, ``behave`` and ``docker-compose``
    52  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    53  
    54  ::
    55  
    56      pip install --upgrade pip
    57      pip install behave nose docker-compose
    58      pip install -I flask==0.10.1 python-dateutil==2.2 pytz==2014.3 pyyaml==3.10 couchdb==1.0 flask-cors==2.0.1 requests==2.4.3 pyOpenSSL==16.2.0 pysha3==1.0b1 grpcio==1.0.4
    59  
    60      #PIP packages required for some behave tests
    61      pip install urllib3 ndg-httpsclient pyasn1 ecdsa python-slugify grpcio-tools jinja2 b3j0f.aop six
    62  
    63  Steps
    64  ~~~~~
    65  
    66  Set your GOPATH
    67  ^^^^^^^^^^^^^^^
    68  
    69  Make sure you have properly setup your Host's `GOPATH environment
    70  variable <https://github.com/golang/go/wiki/GOPATH>`__. This allows for
    71  both building within the Host and the VM.
    72  
    73  In case you installed Go into a different location from the standard one
    74  your Go distribution assumes, make sure that you also set `GOROOT
    75  environment variable <https://golang.org/doc/install#install>`__.
    76  
    77  Note to Windows users
    78  ^^^^^^^^^^^^^^^^^^^^^
    79  
    80  If you are running Windows, before running any ``git clone`` commands,
    81  run the following command.
    82  
    83  ::
    84  
    85      git config --get core.autocrlf
    86  
    87  If ``core.autocrlf`` is set to ``true``, you must set it to ``false`` by
    88  running
    89  
    90  ::
    91  
    92      git config --global core.autocrlf false
    93  
    94  If you continue with ``core.autocrlf`` set to ``true``, the
    95  ``vagrant up`` command will fail with the error:
    96  
    97  ``./setup.sh: /bin/bash^M: bad interpreter: No such file or directory``
    98  
    99  Cloning the Hyperledger Fabric source
   100  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   101  
   102  Since Hyperledger Fabric is written in ``Go``, you'll need to
   103  clone the source repository to your $GOPATH/src directory. If your $GOPATH
   104  has multiple path components, then you will want to use the first one.
   105  There's a little bit of setup needed:
   106  
   107  ::
   108  
   109      cd $GOPATH/src
   110      mkdir -p github.com/hyperledger
   111      cd github.com/hyperledger
   112  
   113  Recall that we are using ``Gerrit`` for source control, which has its
   114  own internal git repositories. Hence, we will need to clone from
   115  :doc:`Gerrit <../Gerrit/gerrit>`.
   116  For brevity, the command is as follows:
   117  
   118  ::
   119  
   120      git clone ssh://LFID@gerrit.hyperledger.org:29418/fabric && scp -p -P 29418 LFID@gerrit.hyperledger.org:hooks/commit-msg fabric/.git/hooks/
   121  
   122  **Note:** Of course, you would want to replace ``LFID`` with your own
   123  :doc:`Linux Foundation ID <../Gerrit/lf-account>`.
   124  
   125  Bootstrapping the VM using Vagrant
   126  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   127  
   128  If you are planning on using the Vagrant developer environment, the
   129  following steps apply. **Again, we recommend against its use except for
   130  developers that are limited to older versions of macOS and Windows that
   131  are not supported by Docker for Mac or Windows.**
   132  
   133  ::
   134  
   135      cd $GOPATH/src/github.com/hyperledger/fabric/devenv
   136      vagrant up
   137  
   138  Go get coffee... this will take a few minutes. Once complete, you should
   139  be able to ``ssh`` into the Vagrant VM just created.
   140  
   141  ::
   142  
   143      vagrant ssh
   144  
   145  Once inside the VM, you can find the source under
   146  ``$GOPATH/src/github.com/hyperledger/fabric``. It is also mounted as
   147  ``/hyperledger``.
   148  
   149  Building Hyperledger Fabric
   150  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   151  
   152  Once you have all the dependencies installed, and have cloned the
   153  repository, you can proceed to :doc:`build and test <build>` Hyperledger
   154  Fabric.
   155  
   156  Notes
   157  ~~~~~
   158  
   159  **NOTE:** Any time you change any of the files in your local fabric
   160  directory (under ``$GOPATH/src/github.com/hyperledger/fabric``), the
   161  update will be instantly available within the VM fabric directory.
   162  
   163  **NOTE:** If you intend to run the development environment behind an
   164  HTTP Proxy, you need to configure the guest so that the provisioning
   165  process may complete. You can achieve this via the *vagrant-proxyconf*
   166  plugin. Install with ``vagrant plugin install vagrant-proxyconf`` and
   167  then set the VAGRANT\_HTTP\_PROXY and VAGRANT\_HTTPS\_PROXY environment
   168  variables *before* you execute ``vagrant up``. More details are
   169  available here: https://github.com/tmatilai/vagrant-proxyconf/
   170  
   171  **NOTE:** The first time you run this command it may take quite a while
   172  to complete (it could take 30 minutes or more depending on your
   173  environment) and at times it may look like it's not doing anything. As
   174  long you don't get any error messages just leave it alone, it's all
   175  good, it's just cranking.
   176  
   177  **NOTE to Windows 10 Users:** There is a known problem with vagrant on
   178  Windows 10 (see
   179  `mitchellh/vagrant#6754 <https://github.com/mitchellh/vagrant/issues/6754>`__).
   180  If the ``vagrant up`` command fails it may be because you do not have
   181  the Microsoft Visual C++ Redistributable package installed. You can
   182  download the missing package at the following address:
   183  http://www.microsoft.com/en-us/download/details.aspx?id=8328
   184  
   185  .. Licensed under Creative Commons Attribution 4.0 International License
   186     https://creativecommons.org/licenses/by/4.0/
   187