Skip to content

Install Sandstorm via Vagrant

Asheesh Laroia edited this page Feb 5, 2015 · 20 revisions

Developing Sandstorm apps on a Mac (or other non-Linux platform)

Sandstorm only runs on Linux, which means if you've got a shiny new Macbook, you've got a couple of options for hacking on Sandstorm, or developing new apps for it.

  1. Dual boot some flavor of Linux (kind of a pain to set up!)
  2. Run a VM on your machine as a desktop app (slow!)
  3. Run a VM on your machine using Vagrant (awesome!)

This page should help you get up and running with Vagrant.

This guide should apply to Windows, too, but we have not yet tested it on Windows.

What is Vagrant

Vagrant is a way to make using a virtual machine (VM) for your dev environment as easy and pleasant as possible.

Vagrant reads a configuration file (typically $PROJECT_ROOT/Vagrantfile) that specifies an OS and a set of provisioning scripts that get you set up with a standard development environment for hacking on $PROJECT. Sandstorm, luckily, has one of these.

In addition to getting a pre-configured VM up and running, Vagrant gives you easy configuration for (1) syncing files between your Host and Guest OS (ie your mac and your linux VM) and (2) for port forwarding. What that means in practice is you mostly don't have to be aware of your VM—you can use whatever OS X text editor and browser you like for development, and Vagrant will happily pipe your files and requests through to the VM.

Getting Started

Vagrant works with a bunch of different virtualization systems. VirtualBox is free, and easy to set up on your Mac. So your first two steps:

  1. Install Vagrant, or brew install vagrant
  2. Install VirtualBox

While that's getting set up, make sure you grab the Sandstorm source files:

git clone [email protected]:sandstorm-io/sandstorm.git

When you've got Virtualbox and Vagrant installed, cd into the sandstorm directory (where you checked out the source) and run:

vagrant up

This will go and fetch a simple version of Ubuntu, and get it set up for Sandstorm. When it's ready, you can run vagrant ssh to access your box, and start up your sandstorm server.

What's Next

If you're working on Sandstorm itself, you're in pretty good shape. Vagrant will mount the sandstorm/ directory to /vagrant/ and sync changes between the two.

If you're developing an app for Sandstorm, you might want to mount your app's directory as well.

Make an edit to the sandstorm/Vagrantfile to mount your app's directory, or make a copy of sandstorm's Vagrant file with similar edits:

      config.vm.synced_folder ".", "/vagrant", disabled: true   # disable the default mounting behavior
      config.vm.synced_folder ".", "/vagrant/sandstorm"         # mount sandstorm to /vagrant/sandstorm  
      config.vm.synced_folder "/Users/<username>/<project-dir>", "/vagrant/<project-dir>" # mount my app's directory to /vagrant

That way you can run spk or meteor-spk inside of vagrant, and have your app files sync'd with my mac for development.

Some Hacks for Meteor

Meteor is awesome, but there's at least one gotcha when trying to run it in Vagrant. After installing Meteor on your Vagrant VM, with the standard meteor installer, and also setting up the meteor-spk tool, you might run into an issue where mongodb refuses to start.

There's a weird interaction between mongodb and Vagrant's folder sharing. A simple workaround is to mount your /vagrant/<project-dir>/.meteor/local folder from somewhere outside of the share. Credit goes to this post on StackOverflow

sudo mount --bind /home/vagrant/<project-dir>/.meteor/local/ /vagrant/<project-dir>/.meteor/local/

And you should be able to start up meteor after that!

Clone this wiki locally