Running on Heroku

Deploying Nesta to Heroku works out of the box. If you haven't already done so, signup for Heroku and install the heroku toolbelt.

Before you can deploy your site you need to get it running properly on your own computer. You'll also need to check it into a Git repository. If you've already done that you can skip ahead, but just in case we'll cover it here quickly with an example.

Setting up git

When you generate a new Nesta site you can tell Nesta that you want to manage it with Git by adding the --git switch:

$ nesta new mysite.com --git

The --git switch just creates a new repository for you, and commits the freshly created site. If you're deploying a site that has been created without a git repository, create a git repository as follows:

$ cd mysite.com
$ git init
$ git add .
$ git commit -m "Initial commit"

You'll need to store your content in a content directory directly inside the top level Nesta directory (which is the default) and check it into the same repository as your copy of Nesta. If you've not already written any content create a test article now and add it to your Git repository:

$ cd mysite.com
$ mkdir -p content/pages
$ cat > content/pages/test.mdown
Date: 16 June 2010

# Demo article

Woohoo!
^D  # <- press Ctrl-D

$ git add .
$ git commit -m "Added an article."

Running the site locally

Start the server up locally (run bundle exec mr-sparkle config.ru) and make sure you can browse to http://localhost:8080/. You should be able to see your content.

Deploying to Heroku

There's no need to push these changes to a remote git repository such as GitHub -- we're going to cut out the middle man and push your repository directly to Heroku.

Make sure that you fill in config/config.yml properly (the most important thing is to ensure that caching is off, as we can't write to Heroku's file system).

$ heroku create
$ git push heroku master

Check whether your deployment worked by visiting your special Heroku URL (which you can find in the output of the heroku info command). See the Heroku documentation for instructions on how to change this URL to something more suitable.

To run Nesta on your own domain you just need to configure Heroku's custom domains.

That's it, you're done.

A note on caching: Experienced Heroku users may be wondering whether Nesta automatically enables any HTTP compliant caching on Heroku. The answer is "not yet", but it's under discussion. In the meantime, as Nesta is a simple Sinatra app you can configure caching just as you would for any other Sinatra app.