Vagrant.configure(2) do |config|

  config.vm.box = "phusion/ubuntu-14.04-amd64"
  config.vm.box_url = "https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vmwarefusion.box"
  config.vm.hostname = "riaktive.leankit.com"

  config.vm.provider "vmware_fusion" do |v|
    v.vmx["memsize"] = "4096"
    v.vmx["numvcpus"] = "2"
  end

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "forwarded_port", guest: 8098, host: 8098
  config.vm.network "forwarded_port", guest: 8087, host: 8087

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  config.vm.network "private_network", ip: "192.168.33.10"

  config.vm.provision :docker do |d|
    d.build_image "/vagrant/.riak/",
      args: "-t riak"

    d.run "riak",
     image: "riak",
     args: "-it --restart=always -v ~/.docker/riak/data:/data -p 8098:8098 -p 8087:8087 --name riak"
  end

  config.vm.provision "shell", run: "always", inline: <<-SHELL
     docker start riak
  SHELL

  config.vm.provision "shell", inline: <<-SHELL
    sleep 5
    docker exec -d riak riak-admin bucket-type create write_once_bucket '{"props":{"write_once":true}}'
    docker exec -d riak riak-admin bucket-type activate write_once_bucket

    docker exec -d riak riak-admin bucket-type create custom_bucket_type '{"props":{"allow_mult":true, "n_val": 10 }}'
    docker exec -d riak riak-admin bucket-type activate custom_bucket_type
  SHELL


end
