Skip to content

Instantly share code, notes, and snippets.

@Mec-iS
Last active February 11, 2019 16:18
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mec-iS/b84758397f1b21f21700 to your computer and use it in GitHub Desktop.
Save Mec-iS/b84758397f1b21f21700 to your computer and use it in GitHub Desktop.

Install BigchainDB on a VM with Vagrant

It's quite easy to provision and run a Vagrant VM:

  • Install Vagrant in your host system following instructions here
  • In your VM-to-be's home directory create the VagrantFile and the bash script to provision the machine (config.sh)

VagrantFile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.provision "shell", path: "config.sh"
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 7000, host: 7000
  config.vm.network "forwarded_port", guest: 5000, host: 5000
end

config.sh

apt-get -qqy update
apt-get -qqy upgrade
apt-get -qqy install build-essential
apt-get -qqy install curl
apt-get -qqy install git
apt-get -qqy install libssl-dev
apt-get -qqy install python3-pip
apt-get -qqy install rethinkdb
python3 -m pip install --upgrade pip
python3 -m pip install bigchaindb
  • run vagrant up to start provisioning (SO and libraries get installed)
  • run vagrant ssh to log in the newly created machine
  • test if working, from VM's command line:
$> python3
>>> from bigchaindb.core import Bigchain
>>> bigchain = Bigchain()
>>> print(bigchain.host)
localhost
>>> print(bigchain.me)
<print the public key of the instance>
@jdevoo
Copy link

jdevoo commented Apr 22, 2016

helpful stuff! just had slight modifications to config.sh:

  1. add libffi-dev and
  2. prepend with
source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -

ah and also run bigchaindb configure before jumping into the Python repl...

@jvsteiner
Copy link

this is great, but im getting:

vagrant@vagrant-ubuntu-trusty-64:~$ python3 -m pip install bigchaindb
Collecting bigchaindb
  Using cached BigchainDB-0.2.0.tar.gz
    Complete output from command python setup.py egg_info:

    Installed /tmp/easy_install-maig5qst/pytest-runner-2.7.1/setuptools_scm-1.11.0-py3.4.egg
    your setuptools is too old (<12)
    setuptools_scm functionality is degraded
    zip_safe flag not set; analyzing archive contents...

    Installed /tmp/pip-build-ks1u413g/bigchaindb/pytest_runner-2.7.1-py3.4.egg
    error in BigchainDB setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ks1u413g/bigchaindb/

any ideas?

@jvsteiner
Copy link

using this now, with some success - i've set it up more as a dev environment so the local copy of bigchaindb is used:

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.provision "shell", path: "config.sh"
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 7000, host: 7000
  config.vm.network "forwarded_port", guest: 5000, host: 5000
  config.vm.synced_folder ".", "/home/vagrant/bigchaindb"
end

config.sh

source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
apt-get -qqy update
apt-get -qqy upgrade
apt-get -qqy install build-essential
apt-get -qqy install curl
apt-get -qqy install git
apt-get -qqy install libssl-dev
apt-get -qqy install libffi-dev
apt-get -qqy install python3-pip
apt-get -qqy install rethinkdb
python3 -m pip install --upgrade pip
python3 -m pip install -r /home/vagrant/bigchaindb/requirements.txt

Note: I had to copy the requirements into a file from setup.py, since this project doesn't have one (as of this writing)

@eledger
Copy link

eledger commented May 26, 2016

I had warnings about old setuptool version so got around that..

pip install -U pip wheel setuptools

@dominic-healid
Copy link

I tried to follow this on windows but it doesn't seem to work. Running vagrant up doesn't do anything.

Any ideas?

@mvgraf
Copy link

mvgraf commented Feb 11, 2019

Working version with Bigchain v2.0:

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.provision "shell", path: "config.sh"
  config.vm.box = "ubuntu/bionic64"
  config.vm.network "forwarded_port", guest: 9984, host: 9984
end

config.sh

# defaults
apt-get -qqy update
apt-get -qqy upgrade
apt-get -qqy install build-essential
apt-get -qqy install curl
apt-get -qqy install git
apt-get -qqy install libssl-dev
#python 3.6
apt-get -qqy install python3-pip
#pip
sudo wget https://bootstrap.pypa.io/get-pip.py
sudo python3.6 get-pip.py
sudo rm get-pip.py
#docker
sudo apt-get -qqy install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -qqy update
sudo apt-get -qqy install docker-ce docker-ce-cli containerd.io
sudo apt-get -qqy install docker-compose
#bigchain
apt-get -qqy install rethinkdb
#python3 -m pip install bigchaindb
rm -r -f bigchaindb
git clone -b rbac https://github.com/bigchaindb/bigchaindb.git
cd bigchaindb
# remove invalid argument for newer pip versions
find . -name "Dockerfile-dev" -type f | xargs sed -i -e 's/ --process-dependency-links//'
# run
sudo make run

Edit the git clone branch as you need. It is currently set to "rbac"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment