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