Develop using Vagrant

In our ongoing effort to make it easier to develop LogicBlox applications, both for beginners and pros, a few months ago we launched the LogicBlox Virtual Appliances. These were downloadable VirtualBox images that came with LogicBlox installed as well as some editors and other useful tools. While this helped many people get started more quickly, the appliances had some issues:

  1. Every LogicBlox release means another 1.5GB download.
  2. You have to do all your development within the graphical user interface of the VM.
  3. All your projects are “locked up” in the VM and you need to push them to a repo to get them out.

While an improvement over manually installing an Ubuntu Linux VM and downloading LogicBlox into it, there is definitely still room for improvement.

Luckily, we’re not the only ones figuring out ways to make it easier for people to get started working on software projects with complex dependencies.

Vagrant is a popular tool used for this purpose. Its tagline:

Create and configure lightweight, reproducible, and portable development environments.

This is how Vagrant works in general:

  1. You install Vagrant as well as VirtualBox.
  2. If your project doesn’t have one already, you add a so-called Vagrantfile to your project. This Vagrantfile describes how to set up a development VM for this particular project.
  3. You cd into your project directory and run a single command: vagrant up

Vagrant will download a Linux VM image for you and install a bunch of software you’ll need (as specified in the Vagrantfile) to start working on the project. It will then configure the VM so that your project files, which live outside the VM, are available from within the VM — usually at the /vagrant path. In addition, it will set up port mapping from your VM to your machine so that you can easily access running web services from outside the VM. You can then run commands within this VM using vagrant ssh.

Cool, no?

So we prepared a Vagrantfile for LogicBlox projects, which is now the preferred way to get started with LogicBlox (especially for Mac and Windows users). Our reference manual includes instructions on how to set it up.

Here’s why you should use it

  1. If you have Vagrant and VirtualBox installed, no matter if you’re running Mac, Linux or Windows (although using Windows is slightly more convoluted): you can now start developing on LogicBlox projects (both 3.10 and 4.0 are supported) without having to download 1.5GB VMs.
  2. If a project you’re working on contains a Vagrantfile, ensure there is a copy (or hardlink) of a LogicBlox release tarball in the project root, and run vagrant up command to get started. The LogicBlox release contained in the tarball is automatically extracted, set up and started for you and any other additional dependencies (nginx, JDK etc.) are installed.
  3. While the software will run in the VM, it feels like you’re developing “natively” on your Mac, Windows or Linux machine:

    • You can edit your project files with any editor you like outside of the VM
    • You can just point your browser to http://localhost:8080 to access LB web, or http://localhost:8086 to access nginx (if you need more ports mapped, configure them in the Vagrantfile) using your favorite browser.
    • An lb_deployment directory is created within your project directory containing configuration files and logs, available for inspection outside of the VM using your favorite tool.
    • You can run compilations and LB commands either through a shell into the Ubuntu Linux VM:

      $ vagrant ssh
      

      or directly, without a shell:

      $ vagrant ssh -c 'lb config && make check'
      
  4. When you’re done, you can either stop the VM temporarily using vagrant halt or destroy it completely using vagrant destroy. Destroying the VM is always perfectly fine, because your project files are not stored in the VM itself.

  5. If you work on multiple LogicBlox projects simultaneously, possibly requiring different versions of the database, Vagrant is a great solution since every project gets its own VM and can therefore be running different versions of LogicBlox simultaneously.

To learn more about using Vagrant with LogicBlox, read our reference manual. To learn more about Vagrant in general and how to adapt the Vagrantfile for your particular needs, read the excellent Vagrant documentation.

2 Comments
  1. Matthew Nizol 9 years ago

    I would like to share the following work-around in the event that others run into this issue on Windows. While attempting to run LB via Vagrant on Windows 8, I received an error message when the lb-compile service attempted to start:

    Exception in thread “main” java.lang.UnsupportedClassVersionError: com/logicblox/compiler/standalone/Main : Unsupported major.minor version 51.0

    After some research online, I determined that major version 51 corresponds to Java version 7. However, the Vagrantfile installs Java version 6 on the VM. I updated line 35 in my local copy of the Vagrantfile from:

    apt-get install -qq -y openjdk-6-jre vim-tiny nginx make

    to

    apt-get install -qq -y openjdk-7-jre vim-tiny nginx make

    Now all lb services successfully start on my vagrant VM.

    Thanks,
    Matt

    • Author
      Zef Hemel 9 years ago

      Thanks! I just updated the Vagrantfile to use JRE 7.

Leave a reply

© Copyright 2023. Infor. All rights reserved.

Log in with your credentials

Forgot your details?