Tuesday, August 18, 2009

Deploying Thoth to Heroku

This is a short instruction how to use Thoth with Heroku. Thoth is a Ruby blog engine, and Heroku is a Ruby hosting platform - there is a convenient free hosting plan. Instructions are targeted towards the latest version of Thoth - 0.3.0.
I'll keep this brief however, first goes disclaimer:
I don't develop in Ruby, I haven't done anything in Ruby yet. All I know about Ruby and Rails is from a book I read long time ago, going through it lightning fast without much retention. There are possible better ways to do this however this approach works. Anyhow, no guarantees.

Get and install the latest version
First of all there is no official 0.3.0 release, or at least I could not find it. Version 0.2.1 did not work on my machine so I had to get the latest version of code, created a gem out of it, installed it and it worked fine after that. Instructions how to get the latest version are at the Thoth homepage.

Create a thoth site
On the same page are instructions how to run it. Create a site, give it whatever name, you'll need to copy those file later on to your heroku application. After following all instructions you can test your new thoth blog.

Create a heroku app
Create your heroku application following instructions from the quick start. You'll need to install git and setup ssh public key. Create heroku application, copy all files from your previously created thoth site, initialize git repository and add files to git. Now everything is practicaly the same as in the quick start - except I could not create thoth site into already existing folder.

Now goes exciting stuff - how to make this really work on heroku.
Getting it all to work
Since there isn't official 0.3.0 version of thoth we need to unpack it into vendor/gems folder of our heroku application first. Then config.ru has to be fixed so that version of thoth is used:

Dir.glob(File.dirname(__FILE__) + "/vendor/gems/*").each do |path|
gem_name = File.basename(path.gsub(/-[\d\.]+$/, ''))
$LOAD_PATH << path + "/lib/"
require gem_name

#require 'thoth'

So require 'thoth' is basically replaced by the code to load all gems from vendor folder - got a bit of help from here.

Now specify all required gems. You can read detailed instructions on installing gems on heroku or just create .gems file with following contents:

innate --version 2009.06.12
ramaze --version 2009.06.12

Fix thoth.config file to use correct database connection:

db: <%= ENV['DATABASE_URL'] || ('sqlite:///'+ (Thoth::HOME_DIR) +'/db/live.db') %>

It's postgresql but it seems to be working for now. Another setting needs to be changed and that is url:
# Base URL of your site. This is necessary in order for Thoth to know how
# to construct links. Be sure to set this correctly or links may not work.
url: http://someappname.heroku.com/

Now everything is almost ready, the only thing left is database. You need to run thoth --migrate to crate ./db/live.db sqlite database. Then push it to heroku following instructions, basically one command - something like: heroku db:push sqlite://db/live.db

After this you can push the whole application to heroku and it should work.

Peace of cake, now you have your free personal blog in Ruby.

Sunday, August 16, 2009

JumpStart is up on google code

I have recently uploaded source code to google code.
The plan is to more frequently publish intermediate releases, and 0.5a4.1 is the first one.
It features improved refresh of the thumbs, localized to Korean (thanks Forrest) and Serbian, made a bit faster by moving thumbs storage to places database.
Hopefully I will be able to push improvements as soon as they happen so changes will be rather small for every release.