github.com/adnan-c/fabric_e2e_couchdb@v0.6.1-preview.0.20170228180935-21ce6b23cf91/devenv/Vagrantfile (about) 1 # -*- mode: ruby -*- 2 # vi: set ft=ruby : 3 4 # This vagrantfile creates a VM with the development environment 5 # configured and ready to go. 6 # 7 # The setup script (env var $script) in this file installs docker. 8 # This is not in the setup.sh file because the docker install needs 9 # to be secure when running on a real linux machine. 10 # The docker environment that is installed by this script is not secure, 11 # it depends on the host being secure. 12 # 13 # At the end of the setup script in this file, a call is made 14 # to run setup.sh to create the developer environment. 15 16 # This is the mount point for the sync_folders of the source 17 SRCMOUNT = "/hyperledger" 18 LOCALDEV = "/local-dev" 19 20 $script = <<SCRIPT 21 set -x 22 23 echo "127.0.0.1 couchdb" | tee -a /etc/hosts 24 25 export DOCKER_STORAGE_BACKEND="#{ENV['DOCKER_STORAGE_BACKEND']}" 26 27 cd #{SRCMOUNT}/devenv 28 ./setup.sh 29 30 SCRIPT 31 32 baseimage_release = File.read '../.baseimage-release' 33 34 Vagrant.require_version ">= 1.7.4" 35 Vagrant.configure('2') do |config| 36 config.vm.box = "hyperledger/fabric-baseimage" 37 config.vm.box_version = ENV['USE_LOCAL_BASEIMAGE'] ? "0": baseimage_release # Vagrant does not support versioning local images, the local version is always implicitly version 0 38 39 config.vm.network :forwarded_port, guest: 7050, host: 7050 # fabric orderer service 40 config.vm.network :forwarded_port, guest: 7051, host: 7051 # fabric peer service 41 config.vm.network :forwarded_port, guest: 7053, host: 7053 # fabric peer event service 42 config.vm.network :forwarded_port, guest: 7054, host: 7054 # fabric-ca service 43 config.vm.network :forwarded_port, guest: 5984, host: 15984 # CouchDB service 44 45 config.vm.synced_folder "..", "#{SRCMOUNT}" 46 config.vm.synced_folder "..", "/opt/gopath/src/github.com/hyperledger/fabric" 47 config.vm.synced_folder ENV.fetch('LOCALDEVDIR', ".."), "#{LOCALDEV}" 48 if File.exist?("../../fabric-ca") 49 config.vm.synced_folder "../../fabric-ca", "/opt/gopath/src/github.com/hyperledger/fabric-ca" 50 end 51 52 config.vm.provider :virtualbox do |vb| 53 vb.name = "hyperledger" 54 vb.customize ['modifyvm', :id, '--memory', '4096'] 55 vb.cpus = 2 56 57 storage_backend = ENV['DOCKER_STORAGE_BACKEND'] 58 case storage_backend 59 when nil,"","aufs","AUFS" 60 # No extra work to be done 61 when "btrfs","BTRFS" 62 # Add a second disk for the btrfs volume 63 IO.popen("VBoxManage list systemproperties") { |f| 64 65 success = false 66 while line = f.gets do 67 # Find the directory where the machine images are stored 68 machine_folder = line.sub(/^Default machine folder:\s*/,"") 69 70 if line != machine_folder 71 btrfs_disk = File.join(machine_folder, vb.name, 'btrfs.vdi') 72 73 unless File.exist?(btrfs_disk) 74 # Create the disk if it doesn't already exist 75 vb.customize ['createhd', '--filename', btrfs_disk, '--format', 'VDI', '--size', 20 * 1024] 76 end 77 78 # Add the disk to the VM 79 vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', btrfs_disk] 80 success = true 81 82 break 83 end 84 end 85 raise Vagrant::Errors::VagrantError.new, "Could not provision btrfs disk" if !success 86 } 87 else 88 raise Vagrant::Errors::VagrantError.new, "Unknown storage backend type: #{storage_backend}" 89 end 90 91 end 92 93 config.vm.provision :shell, inline: $script 94 end