I’ve discovered various degrees of up-to-datedness and accuracy in some of the tutorials out there for deploying an app built on Radiant CMS to Heroku, so here’s one that is valid for the latest Radiant CMS release (0.8.1).
This tutorial assumes that you have already installed and configured the following:
- Rails (2.3.4)
- Git (1.6.4.1)
- Heroku gem (1.3.0)
Specifically, it also assumes that you either a) have configured an ssh keys for use with git, or b) know how to deal with it if you haven’t.
If you don’t meet all of the above criteria, get crackin’… but once you’re ready, read on.
Install gems:
You’ll need, at bare minimum, the radiant (v0.8.1), taps (v0.2.19), and rspec (v1.2.9) gems.
1 | $ sudo gem install radiant |
1 | $ sudo gem install taps |
1 | $ sudo gem install rspec |
Create your app
1 | $ radiant --database sqlite3 testApp |
This step automagically creates your Radiant app, and spits out the names of the files it creates followed by a set of instructions for completing installation. Ignore what you see there and follow these instructions instead.
Create your database
1 2 | $ cd testApp $ rake db:bootstrap |
This will set up the necessary database structure in your local install. There are a few options you’ll need to select:
1 | This task will destroy any data in the database. Are you sure you want to continue? [yn] y |
1 2 3 4 | Create the admin user (press enter for defaults). Name (Administrator): Username (admin): Password (radiant): |
1 | Initializing configuration.........OK |
1 2 3 4 5 6 | Select a database template: 1. Empty 2. Roasters (a coffee-themed blog / brochure) 3. Simple Blog 4. Styled Blog [1-4]: (try out 2) |
Get git
1 | $ git init |
Initializes your new git repository. If you don’t get git, get it here
Make caching Heroku-Friendly
In your environment config file (config/environment.rb), you need to update the cache configuration. Heroku’s file system is read-only, so all cache must be written in the tmp directory.
replace config.middleware.use ::Radiant::Cache:
1 2 3 | config.middleware.use ::Radiant::Cache, :entitystore => "radiant:tmp/cache/entity", :metastore => "radiant:tmp/cache/meta" |
Let Heroku know what gems you need.
Since direct access to the command line is not available on the heroku server, create a .gems file to let Heroku know what gems (and what versions of the gems!) are required for your app. When you push your project, the required gems will automagically be installed for you.
1 | $ vi .gems |
1 |
1 2 3 4 | ---------------------- rspec --version 1.2.9 radiant --version 0.8.1 ---------------------- |
Check in
1 2 | $ git add . $ git commit -m "changed cache dir and added gem manifest" |
Deploy!
1 2 3 4 | $ heroku create soychickas-brain2:testApp soychicka$ heroku create Created http://severe-waterfall-89.heroku.com/ | git@heroku.com:severe-waterfall-89.git Git remote heroku added |
The returned lines will include the url for your new app, and the address of the git repository pushed to heroku.
1 2 3 4 5 | $git push heroku master -----> Rails app detected Compiled slug size is 7.8MB -----> Launching............ done http://severe-waterfall-89.heroku.com deployed to Heroku |
is what you should see if all goes well. You can see that the server was started, so you’re almost ready to go. But first, you need to…
Push your database to Heroku
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | heroku db:push Auto-detected local database: sqlite://db/development.sqlite3.db Sending schema Sending data 9 tables, 82 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 Resetting sequences |
is what you should see if all goes well here.
At this point, your app should be live at the url you received when deploying. Make sure to check it out before tinkering with anything… and then you know that you have a safe starting point to return to when you have caused what otherwise would have been irreparable damage to your app.
On that note, I’d recommend taking advantage of Heroku’s new Bundles feature that lets you create an archive (tarball) of your application code repository and a dump of the database. By default, the bundle is stored on the Heroku servers, but you can download the bundle to your local machine, keep one or more on Heroku (, upload bundles from your local machine and re-animate a bundle with the “heroku bundles” commands. You can get one bundle for free, or unlimited bundles for $20/month. The re-animation process seems a little wonky for the time being, but it’s a good option if you want to unabashedly tinker with abandon (and without fear).
So there’s a simple installation path for deploying a standard Radiant application on Heroku. Play around with your install and see if it suits your needs.
Heads up, though: if you want to install extensions in your Heroku-deployed app, there is a custom path for that too! Using the built-in ./script/extension install extensionName doesn’t play nicely with heroku – it installs the extensions as submodules, which are not supported by Heroku at this time.
No related posts.
Recent Comments