Frank on Heroku is simply a Frank project template that makes it easy to host a Frank-based static site on Heroku.
Frank is useful Ruby gem that lets you build static sites using your favorite libs. Frank has a built in development server for previewing work as you develop, an "export" command for compiling and saving your work out to static html and css, and a publish command for copying your exported pages to a server.
Heroku's Cedar Stack makes it easy to host a Rack app
by adding a config.ru
file to the root of the project. Frank on Heroku includes a config.ru
file
that tells Heroku how to serve up files from the /exported
folder in a Frank project.
-
Prebuilt
config.ru
file that includes Ryan Tomayko's TryStatic class which will try and match requests to a static file in the/exported
folder (the default export folder for Frank).http://www.example.com # => returns /exported/index.html http://www.example.com/about # => returns /exported/about.html http://www.example.com/tour/request-a-demo # => returns /exported/tour/request/request-a-demo.html
-
Includes
/heartbeat
request handler that serves a simple200
response. Great for uptime monitoring. -
404
("File not found") error handling automatically serves/exported/404.html
to the user.
-
Make sure frank gem is installed. Install the gem if not:
$ gem install frank
-
Clone frank-on-heroku files into
~/.frank_templates
$ cd ~/.frank_templates/ $ git clone git://github.com/rarestep/frank-on-heroku.git
-
cd
to the directory where your website code will live (e.g.cd ~/Dev
) -
Create the new Frank project using the frank-on-heroku template:
$ frank new rarestep-www Frank is... - Creating your project 'rarestep-www' Which template would you like to use? 1. default 2. frank-on-heroku > 2 - Copying frank-on-heroku Frank template Congratulations, 'rarestep-www' is ready to go! $ cd rarestep-www/
-
Install
Gemfile
gems using Bundler (it's a good idea to to create a newgemset
using RVM for your site):$ rvm gemset create rarestep-www $ rvm gemset use rarestep-www $ bundle install
-
Run the Frank server locally and make sure you can pull up the stie (open http://localhost:3601/ in a web browser to view):
$ bundle exec frank server ----------------------- Frank's takin' care of business... 0.0.0.0:3601 >> Thin web server (v1.3.1 codename Triple Espresso) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:3601, CTRL+C to stop
-
Create a new app on Heroku on the Cedar Stack:
$ heroku create --stack cedar Creating severe-sky-5191... done, stack is cedar http://severe-sky-5191.herokuapp.com/ | [email protected]:severe-sky-5191.git Git remote heroku added
-
Export your site using Frank's
export
command,commit
to git andpush
to Heroku:$ bundle exec frank export A folder named `exported' already exists, overwrite it? [y/n] y Frank is... - Creating 'exported' - Creating 'exported/css/frank.css' - Creating 'exported/index.html' - Creating 'exported/css/frank.css' - Copying static content Congratulations, project dumped to 'exported' successfully! $ git commit -a -m "Exported site" $ git push heroku master $ heroku open
Super easy! Pushing updates is as simple as using Frank as normal to build out your site, then repeating Step #6 above when you're ready to push to Heroku.