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:
- Every LogicBlox release means another 1.5GB download.
- You have to do all your development within the graphical user interface of the VM.
- 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:
- You install Vagrant as well as VirtualBox.
- If your project doesn’t have one already, you add a so-called
Vagrantfileto your project. This
Vagrantfiledescribes how to set up a development VM for this particular project.
cdinto your project directory and run a single command:
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
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
- 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.
- 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 upcommand 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.
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:8080to access LB web, or
http://localhost:8086to access nginx (if you need more ports mapped, configure them in the
Vagrantfile) using your favorite browser.
lb_deploymentdirectory 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'
When you’re done, you can either stop the VM temporarily using
vagrant haltor destroy it completely using
vagrant destroy. Destroying the VM is always perfectly fine, because your project files are not stored in the VM itself.
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.