From 965f5f12101aa793d8bd85d536d7640fae994ef2 Mon Sep 17 00:00:00 2001 From: Sanjay S B Date: Thu, 31 Jan 2019 12:33:31 +0530 Subject: [PATCH 1/5] Create and test vagrant file --- .gitignore | 1 + Vagrantfile | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .gitignore create mode 100644 Vagrantfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94695ea --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vagrant/ \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..fce322c --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,89 @@ +$script = <<-SCRIPT + +echo "cd /vagrant" >> /home/vagrant/.profile +echo "The Virtual Machine is up" +SCRIPT + +Vagrant.configure("2") do |config| + + + config.vm.box = "bento/ubuntu-16.04" + + config.ssh.username = 'vagrant' + config.ssh.password = 'vagrant' + config.ssh.insert_key = 'true' + + + # Ports foward + # For SSH + # config.vm.network "forwarded_port", guest: 2222, host: 2222 + # For playground + config.vm.network "forwarded_port", guest: 8080, host: 8080 + + # For REST Server + config.vm.network "forwarded_port", guest: 3000, host: 3000 + + # For Docker Deamon + config.vm.network "forwarded_port", guest: 2375, host: 2375 + + # For Orderer Container + config.vm.network "forwarded_port", guest: 7050, host: 7050 + + # For Peer Containers of Founder + config.vm.network "forwarded_port", guest: 7051, host: 7051 + config.vm.network "forwarded_port", guest: 7052, host: 7052 + config.vm.network "forwarded_port", guest: 7053, host: 7053 + + # For Peer Containers of First + config.vm.network "forwarded_port", guest: 8051, host: 8051 + config.vm.network "forwarded_port", guest: 8052, host: 8052 + config.vm.network "forwarded_port", guest: 8053, host: 8053 + + # For Peer Containers of Second + config.vm.network "forwarded_port", guest: 9051, host: 9051 + config.vm.network "forwarded_port", guest: 9052, host: 9052 + config.vm.network "forwarded_port", guest: 9053, host: 9053 + + # For Peer Containers of Third + config.vm.network "forwarded_port", guest: 10051, host: 10051 + config.vm.network "forwarded_port", guest: 10052, host: 10052 + config.vm.network "forwarded_port", guest: 10053, host: 10053 + + # For CA Container + config.vm.network "forwarded_port", guest: 7054, host: 7054 + + # For CouchDB Container + config.vm.network "forwarded_port", guest: 5984, host: 5984 + + # For Kafka Manager + config.vm.network "forwarded_port", guest: 9000, host: 9000 + + + # This gets executed for both vm1 & vm2 + #config.vm.provision "shell", inline: "echo 'All good'" + config.vm.provision "shell", inline: $script + + # To use a diffrent Hypervisor create a section config.vm.provider + # And comment out the following section + # Configuration for Virtual Box + config.vm.provider :virtualbox do |vb| + # Change the memory here if needed - 2 Gb memory on Virtual Box VM + vb.customize ["modifyvm", :id, "--memory", "2048", "--cpus", "1"] + # Change this only if you need destop for Ubuntu - you will need more memory + vb.gui = false + # In case you have DNS issues + # vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + end + + # Configuration for Windows Hyperv + config.vm.provider :hyperv do |hv| + # Change the memory here if needed - 2 Gb memory on Virtual Box VM + hv.customize ["modifyvm", :id, "--memory", "2048", "--cpus", "1"] + # Change this only if you need destop for Ubuntu - you will need more memory + hv.gui = false + # In case you have DNS issues + # vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + end + + + end \ No newline at end of file From 39b843e8241d3a4b479823a7c91796b883ba7aa2 Mon Sep 17 00:00:00 2001 From: Sanjay S B Date: Wed, 6 Feb 2019 10:15:57 +0530 Subject: [PATCH 2/5] create docker installation script file --- setups/install-docker.sh | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 setups/install-docker.sh diff --git a/setups/install-docker.sh b/setups/install-docker.sh new file mode 100644 index 0000000..abd07e8 --- /dev/null +++ b/setups/install-docker.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Install docker in the virtual machine using this script +# For more detail visit https://docs.docker.com/install/linux/docker-ce/ubuntu/ + +# The commands need to be executed with sudo. use sudo ./install-docker.sh +if [ -z $SUDO_USER ] +then + echo "===== script needs to be executed by super user ====" + exit 0 +fi + +# SET UP THE REPOSITORY + +# update the apt package +apt-get update + +# install packages to allow apt to use a repository over HTTPS +apt-get install \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg-agent \ + software-properties-common + +# add docker's official gpg key +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + +# verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, +# by searching for the last 8 characters of the fingerprint. + +apt-key fingerprint 0EBFCD88 + +# pub rsa4096 2017-02-22 [SCEA] +# 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 +# uid [ unknown] Docker Release (CE deb) +# sub rsa4096 2017-02-22 [S] + +# set up the stable repository +add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + +# update the apt package +apt-get update + +# install latest version of +apt-get install docker-ce docker-ce-cli containerd.io + +echo "trying to run the hello world container" + +docker run hello-world + +# logout of vagrant. Login to check if docker is installed properly + +echo "vagrant ssh and check docker --version" +exit + + + + From a1ccba86f47d3e1ed631fa87a807ff47e837146c Mon Sep 17 00:00:00 2001 From: Sanjay S B Date: Wed, 6 Feb 2019 10:33:53 +0530 Subject: [PATCH 3/5] update the vagrant file for increased timeout and box name --- README.md | 10 ++++++++++ Vagrantfile | 2 ++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 060c957..250c4b7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,12 @@ # chaincode-testing A project for testing hyperledger fabric chaincodes quickly and efficiently + +########################## +# HOW TO USE THIS PROJECT +########################## +In the root folder run + +$ vagrant up + +$ vagrant ssh + diff --git a/Vagrantfile b/Vagrantfile index fce322c..4e9d897 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -8,6 +8,7 @@ Vagrant.configure("2") do |config| config.vm.box = "bento/ubuntu-16.04" + config.vm.boot_timeout = 600 config.ssh.username = 'vagrant' config.ssh.password = 'vagrant' @@ -67,6 +68,7 @@ Vagrant.configure("2") do |config| # And comment out the following section # Configuration for Virtual Box config.vm.provider :virtualbox do |vb| + vb.name = "chaincode-testing" # Change the memory here if needed - 2 Gb memory on Virtual Box VM vb.customize ["modifyvm", :id, "--memory", "2048", "--cpus", "1"] # Change this only if you need destop for Ubuntu - you will need more memory From feab89ba4c3dcd8635597a52a7b07ba840f5c17c Mon Sep 17 00:00:00 2001 From: Sanjay S B Date: Wed, 6 Feb 2019 12:31:32 +0530 Subject: [PATCH 4/5] Update the readme and docker installation files as per testing --- README.md | 8 ++++ setups/install-docker.sh | 95 ++++++++++++++-------------------------- 2 files changed, 42 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 250c4b7..6d95717 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,11 @@ $ vagrant up $ vagrant ssh +In the vagrant shell vagrant@vagrant:/vagrant$, run the following commands + +$ cd setups/ +$ chmod 777 install-docker.sh +$ sudo bash ./install-docker.sh + +On prompt Do you want to continue? [Y/n] enter y (might need to do it twice) + diff --git a/setups/install-docker.sh b/setups/install-docker.sh index abd07e8..420ba90 100644 --- a/setups/install-docker.sh +++ b/setups/install-docker.sh @@ -1,61 +1,34 @@ -#!/bin/sh -# Install docker in the virtual machine using this script -# For more detail visit https://docs.docker.com/install/linux/docker-ce/ubuntu/ - -# The commands need to be executed with sudo. use sudo ./install-docker.sh -if [ -z $SUDO_USER ] -then - echo "===== script needs to be executed by super user ====" - exit 0 -fi - -# SET UP THE REPOSITORY - -# update the apt package -apt-get update - -# install packages to allow apt to use a repository over HTTPS -apt-get install \ - apt-transport-https \ - ca-certificates \ - curl \ - gnupg-agent \ - software-properties-common - -# add docker's official gpg key -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - -# verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, -# by searching for the last 8 characters of the fingerprint. - -apt-key fingerprint 0EBFCD88 - -# pub rsa4096 2017-02-22 [SCEA] -# 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 -# uid [ unknown] Docker Release (CE deb) -# sub rsa4096 2017-02-22 [S] - -# set up the stable repository -add-apt-repository \ - "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" - -# update the apt package -apt-get update - -# install latest version of -apt-get install docker-ce docker-ce-cli containerd.io - -echo "trying to run the hello world container" - -docker run hello-world - -# logout of vagrant. Login to check if docker is installed properly - -echo "vagrant ssh and check docker --version" -exit - - - - +#!/bin/bash +# Install docker in the virtual machine using this script +# For more detail visit https://docs.docker.com/install/linux/docker-ce/ubuntu/ + +# SET UP THE REPOSITORY + +# update the apt package +apt-get update + +# install packages to allow apt to use a repository over HTTPS +apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common + +# add docker's official gpg key +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - + +# verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, +apt-key fingerprint 0EBFCD88 + +# pub rsa4096 2017-02-22 [SCEA] +# 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 +# uid [ unknown] Docker Release (CE deb) +# sub rsa4096 2017-02-22 [S] + +# set up the stable repository +add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + +# INSTALL DOCKER CE +# update the apt package +apt-get update + +# install latest version of docker +apt-get install docker-ce docker-ce-cli containerd.io + +docker run hello-world \ No newline at end of file From c2ea17246dcdc720a7ee847a9c035bca15889013 Mon Sep 17 00:00:00 2001 From: Sanjay S B Date: Wed, 6 Feb 2019 18:06:29 +0530 Subject: [PATCH 5/5] update the files to provision docker in the machine using Vagrantfile --- README.md | 6 +++++- Vagrantfile | 2 ++ setups/install-docker.sh | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d95717..864fd0f 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,13 @@ $ vagrant ssh In the vagrant shell vagrant@vagrant:/vagrant$, run the following commands +$ docker --version + +If docker is not installed, you can try(skip if installed): + $ cd setups/ $ chmod 777 install-docker.sh $ sudo bash ./install-docker.sh -On prompt Do you want to continue? [Y/n] enter y (might need to do it twice) + diff --git a/Vagrantfile b/Vagrantfile index 4e9d897..f647b62 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -63,6 +63,8 @@ Vagrant.configure("2") do |config| # This gets executed for both vm1 & vm2 #config.vm.provision "shell", inline: "echo 'All good'" config.vm.provision "shell", inline: $script + + config.vm.provision "docker" # To use a diffrent Hypervisor create a section config.vm.provider # And comment out the following section diff --git a/setups/install-docker.sh b/setups/install-docker.sh index 420ba90..b4669dc 100644 --- a/setups/install-docker.sh +++ b/setups/install-docker.sh @@ -8,7 +8,7 @@ apt-get update # install packages to allow apt to use a repository over HTTPS -apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common +apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common # add docker's official gpg key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - @@ -29,6 +29,6 @@ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $( apt-get update # install latest version of docker -apt-get install docker-ce docker-ce-cli containerd.io +apt-get install -y docker-ce docker-ce-cli containerd.io docker run hello-world \ No newline at end of file