Deployment to Heroku

Deployment to Heroku

We recommend AWS OpsWorks without hesitation because we based our own services on it. However, for quick results, we'll show you how to deploy to Heroku. Scrivito heavily relies on a large file system for caching which Heroku doesn't offer, but you can easily provide a second-level data cache later on. This document describes how to deploy the new Rails app you previously set up while Preparing Your Project.

Heroku is a PaaS provider that makes it dead-simple to deploy your application.
Learn more at Heroku.

The following instructions are condensed versions of instructions taken from the Heroku Quickstart and Getting Started with Rails 5 guides. Please refer to these documents for further details and explanations.

1. Install Heroku

First, sign up, visit the Heroku Toolbelt page, then download and install the package that fits your operating system.

Now, log in with the Heroku command line tool, providing your Heroku user name and login. This command also creates an SSH key pair and uploads the public key to Heroku:

2. Prepare your application

First, Heroku no longer needs rails_12factor with Rails 5 but does need an environment configuration, as noted in the Heroku instructions. Also, specify the Ruby version Heroku should use. Rails 5 requires Ruby >= 2.2.0, so you might use 2.3.1, for example:

In the production environment, Scrivito won't let anyone edit content in place until permissions have been configured accordingly. If you would like to test your Heroku application as soon as possible even if no such configuration exists, you can add the following section to config/initializers/scrivito.rb. This code makes every user a system user, granting them access to in-place editing:

Be aware that this allows anyone to use the in-place editing interface. Use this code only temporarily for quick testing. For more information about permissions, please refer to the Introduction to Permissions.

If your application is not yet stored in a Git repository, please initialize one and commit the application code:

If your project needs an additional relational database for ActiveRecord, then please add a configuration section for the production environment to the config/database.yml file. You can find the corresponding credentials in your Heroku account. Note that Heroku does not allow deployments with SQLite, but provides a free PostgreSQL database as a service instead.

3. Configure Heroku

Create a Rails application at Heroku and connect it to your local project:

Your Rails application requires credentials and a secret key base to be available at runtime. Since it is bad practice to commit sensitive data to a repository, Heroku's approach is to use environment variables. Scrivito itself uses this kind of configuration, too.

4. Deploy the application

Now, push the master branch to Heroku to start the deployment:

When the deployment ist done, please open the app in the browser, using the URL that was output by the deploy command, e.g. https://my-scrivito-app.herokuapp.com.

5. Mind caching

Use a second-level data cache to compensate for Heroku's volatile file system.

What's next?

If you're new to Scrivito, you might walk the Scrivito Landscape.