Getting Typo 5.4 running on Heroku
Since this is a Typo blog and it's running on Heroku, I decided my first actual post would be to describe the steps I took to actually get this blog up and running. I'm going to try to finish this before lunch! Also, please note if you're unfamiliar with using input redirects using cat, whenever you see a '^D', it simply means to press ctrl-d, which is a unix shortcut for "end of input".
Getting started
-
For running the "edge"; version of Typo, simply clone the git repo and create a couple of folders and files:
$ git clone http://github.com/fdv/typo.git $ cd typo $ mkdir public/files $ touch public/files/.gitkeep $ mkdir tmp $ mkdir tmp/cache $ touch tmp/cache/.gitkeep - If you want to use the stable version, go here, download the stable version, extract it, get into the folder, and initialize it as a git repo:
$ cd typo [or wherever] $ git init $ git add * $ git commit -m 'Base Typo package' $ touch public/files/.gitkeep $ touch tmp/cache/.gitkeep
Disable writing to the Filesystem
Since Heroku is a read-only file system, we have to tell Typo to not even try to write to the filesystem. Easy:
$ cat > config/preinitializer.rb
require 'fileutils'
file_utils_no_write = FileUtils::NoWrite
Object.send :remove_const, :FileUtils
FileUtils = file_utils_no_write
^D
Tell Heroku about the gems you need
Apparently, Heroku has the RedCloth and addressable gems installed by default and skips them unless you have them downloaded from a different source, which is the reason for the '--source gemcutter.org' on these gems below. You may be thinking, "well if Heroku has them installed by default, why am I including them?" The reason is that I don't know. For me, it only worked like this. And since I'm trying to get this done before lunch, I really don't have time to speculate as to why. If you figure out a better way, please leave it in the comments!
$ cat > .gems
htmlentities
calendar_date_select
bluecloth ~> 2.0.5
coderay ~> 0.8
will_paginate ~> 2.3.11
panztel-actionwebservice = 2.3.5
mini_magick ~> 1.2.5
RedCloth --source gemcutter.org --version '~> 4.2.2'
addressable --source gemcutter.org --version '~> 2.1.0'
^D
Get your app going
- First, we need to add all of the changes we just made into our git repo:
$ git add .gems public/files/.gitkeep tmp/cache/.gitkeep config/preinitializer.rb $ git commit -m "Initial Typo on Heroku Setup" - Now, create your site and push your repo up to it. If you don't have a heroku account, get one! You won't be sorry. Come to think of it, why are you reading this if you don't use Heroku? Start. Now. Seriously.
$ heroku create [your_app_name] $ git push heroku master - Now, initialize the database at your shiny new Heorku app.
$ heroku rake db:migrate
Start blogging!
You should be able to hit your new app and go through the Typo setup process now by navigating to http://[your_app_name].heroku.com !
Content borrowed heavily from Mark Catley's Tumblr
about 1 month later:
Instead of doing
$ cat > public/files/.gitkeep ^D
you might just want to use touch in the future e.g.
$ touch public/files/.gitkeep
You won’t have to exit out with EOF (i.e. ^D) for empty files then.