Radiant CMS in 5 Minutes Or Less

Radiant logo

Radiant is an excellent Rails-based Content Management System (CMS). It was created by John W. Long and Sean Cribbs, and has been around for a couple of years, growing steadily in popularity. With the recent addition of taps and gem manifeststs, it’s super-easy to get this lightweight CMS up and running on Heroku.

Start by installing the latest radiant gem on your local box:

$ sudo gem install radiant

Now use the radiant command-line tool to set up your Radiant CMS locally. We’ll use SQLite as the local database:

$ radiant --database sqlite mycms
$ cd mycms
$ rake db:bootstrap

Before we can push to Heroku, we’ll need to initialize a git repo in our project directory:

$ git init

By default, Radiant caches CMS pages in RAILS_ROOT/cache. This won’t work with Heroku’s read-only file system, so before deploying we’ll change it to make sure cached files are written in the tmp directory. Open up your config/environment.rb, and change the cache config line so it reads:

config.action_controller.page_cache_directory = "#{RAILS_ROOT}/tmp/cache"

We’ll also add a gem manifest to make sure the radiant gem is installed on Heroku when we push. Radiant depends on rSpec 1.2.2, so our .gems file should look like this:

rspec --version 1.2.2
radiant --version 0.7.1

Then commit your changes:

$ git add .
$ git commit -m "changed cache dir and added gem manifest"

Now it’s time to create an app on Heroku and deploy this baby to it.

$ heroku create
Created http://vivid-fog-54.heroku.com/ | git@heroku.com:vivid-fog-54.git
Git remote heroku added
$ git push heroku master
....
-----> Heroku receiving push
-----> Rails app detected
       Compiled slug size is 5.4MB
-----> Launching.......... done
       App deployed to Heroku

Finally, we’ll transfer over our local database using taps:

$ heroku db:push
Auto-detected local database: sqlite://db/development.sqlite3
Sending schema
Sending data
9 tables, 57 records
schema_migrat: 100% |==================| Time: 00:00:00
config:        100% |==================| Time: 00:00:00
page_parts:    100% |==================| Time: 00:00:00
extension_met: 100% |==================| Time: 00:00:00
sessions:      100% |==================| Time: 00:00:00
pages:         100% |==================| Time: 00:00:00
snippets:      100% |==================| Time: 00:00:00
layouts:       100% |==================| Time: 00:00:00
users:         100% |==================| Time: 00:00:00
Sending indexes

And now our Radiant instance is live and ready to go!

Radiant on Heroku

Rails 2.3

The Rails 2.3.2 gem is now installed and available for use on Heroku. To learn more about what’s new and improved, check the official Rails blog post.

Enjoy!

Gem Manifests

Gem installation and management has always been pain when the time comes to deploy an app. Rails 2.1 made good progress in this area with gem dependency specifications, allowing you to vendor required gems with a of set rake commands. That’s the method we’ve been recommending for Heroku apps until now, but it does leave important problems unsolved.

First, a substantial limitation of the vendoring method is that it only works with pure Ruby gems. Many apps depend on gems with native extensions that need to be compiled on the deployment target. It’s no good compiling a gem on your Mac laptop and trying to deploy the resulting binary to a Linux host.

Then there’s the issue of adding extra bulk to your code repo by checking in vendored gems. Bulkier repos cause slower deploys, and slower usually equates to fewer. From a process perspective, the net result is decreasing the agility of your codebase. And in a cloud computing environment, these translate to direct scalability consequences: big repos don’t scale as fast as lean ones.

A next-generation web host should have a next-generation solution to this problem. Today we’re excited to introduce just such a solution: gem manifests, the new standard for gem installation and dependency management on Heroku!

Here’s the skinny: add a file named “.gems” (this is your gem manifest) to the root of your app. Here you can list your gems in a format identical to what you would pass to “gem install” on the command line:

hpricot --version '>= 0.2' --source code.whytheluckystiff.net
dm-core --version 0.9.10

Commit the file, git push to Heroku, and watch as your gems are fetched and installed. For Hpricot, native extensions are compiled before your very eyes!

$ git add .gems
$ git commit -m "added gem manifest"

$ git push heroku master
Counting objects: 4, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 356 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)

-----> Heroku receiving push

-----> Installing gem hpricot >= 0.2 from http://code.whytheluckystiff.net
       Building native extensions.  This could take a while...
       Successfully installed hpricot-0.6
       1 gem installed

-----> Installing gem dm-core 0.9.10 from http://gems.rubyforge.org
       Successfully installed addressable-2.0.2
       Successfully installed extlib-0.9.10
       Successfully installed data_objects-0.9.11
       Successfully installed dm-core-0.9.10
       4 gems installed

-----> Verifying repository integrity... done, looks like a Rails app.
       Compiled slug size is 4.3MB
-----> Launching.............. done
       App deployed to Heroku

To git@heroku.com:vivid-moon-60.git
   91425e3..fe10e87  master -> master

As you can see, this gem manifest is lightweight, framework-agnostic (works great with Sinatra), and won’t add any weight to your repo since installation is done in the cloud. Your gems are automatically in the require path, so you can pull them into your app easy-as-pie. Finally, gems are only compiled when the manifest changes, so subsequent deploys will be fast as ever.

Check out the docs, take it for a test-drive, and tell us what you think.

Browse the blog archives or subscribe to the full-text feed.