Deploying with Vlad

Though Heroku is awesome, it isn't for everybody. You get more flexibility if you deploy Nesta to your own web server. For example, you can install themes as submodules (allowing you to pull in the author's latest changes), or run multiple applications using different technologies on the same domain.

Getting Nesta running

Nesta works just like any other Sinatra application and can be setup with a range of web servers. I'm a fan of both Phusion Passenger and Unicorn running behind Nginx, but you can use Apache just as easily.

I'm not going to go into details on setting up a production Ruby web stack here, as there's every chance that you already know what you're doing.

Once your stack is up and running you need to push your site to your server. I have historically used Vlad in favour of Capistrano, but you can do it any way you like. Capistrano has improved a lot since I chose to use Vlad and I suspect I'd use Capistrano now if I was configuring a new server. If you want a step by step guide to setting up a deployment system my article on deploying Sinatra with Vlad may come in handy.

Enabling page caching

If you'd like to write the HTML and CSS that Nesta generates to disk the first time that they're requested, so that your web server (e.g. Nginx or Apache) can serve it directly from the disk on subsequent requests, see the docs on setting up page caching.

Installing themes as Git submodules

Installing themes as submodules makes it very easy to keep your chosen theme up to date with the author's latest changes.

Using a Git submodule is only slightly more involved than committing the theme to your local repository. Instead of nesta theme:install, type this:

$ git submodule add <url> themes/theme-name
$ git submodule update --init
$ nesta theme:enable theme-name  # updates config.yml
$ git add config/config.yml themes/theme-name
$ git commit -m "Switched to the theme-name theme."

When you deploy your code you need to run git submodule update to ensure that the latest version of your theme is deployed (if you're deploying with Vlad this will be taken care of automatically).

In order to update your theme cd into the theme's directory, pull in the latest changes, and then commit the updated submodule to your main repository:

$ cd themes/theme-name
$ git pull
$ cd -
$ git add themes/theme-name
$ git commit -m "Updated the theme-name theme."

Sadly Git submodules aren't an option if you're deploying to Heroku, as Heroku doesn't support them. Some people also find submodules fiddly to maintain, and Gerhard Lazu has suggested giternal as a suitable replacement. I've not had a chance to try giternal yet, but wonder if it'll also work on Heroku...