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/README.md b/README.md index 060c957..864fd0f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ # 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 + +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 + + + diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..f647b62 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,93 @@ +$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.vm.boot_timeout = 600 + + 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 + + config.vm.provision "docker" + + # 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| + 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 + 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 diff --git a/setups/install-docker.sh b/setups/install-docker.sh new file mode 100644 index 0000000..b4669dc --- /dev/null +++ b/setups/install-docker.sh @@ -0,0 +1,34 @@ +#!/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 -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 - + +# 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 -y docker-ce docker-ce-cli containerd.io + +docker run hello-world \ No newline at end of file