Heroku Buildpack Octopress
A fork of the official Ruby Buildpack with support for generating an Octopress static site during the build/deploy stage.
Inspired by the heroku-buildpack-ruby-octopress from Jason Garber but updated to work with the new Heroku Bundler method of specifying a Ruby version.
Usage
To use this build pack prepare your Octopress install according to the original instructions from Jason Garber.
heroku create --buildpack https://github.com/nicholasmott/heroku-buildpack-octopress.git
or add this buildpack to your current app
heroku config:add BUILDPACK_URL=https://github.com/nicholasmott/heroku-buildpack-octopress.git
Hacking
To use this buildpack, fork it on Github. Push up changes to your fork, then create a test app with --buildpack <your-github-url>
and push to it.
To change the vendored binaries for Bundler, Node.js, and rails plugins, use the rake tasks provided by the Rakefile
. You'll need an S3-enabled AWS account and a bucket to store your binaries in as well as the vulcan gem to build the binaries on heroku.
For example, you can change the vendored version of Bundler to 1.1.rc.
First you'll need to build a Heroku-compatible version of Node.js:
$ export AWS_ID=xxx AWS_SECRET=yyy S3_BUCKET=zzz
$ s3 create $S3_BUCKET
$ rake gem:install[bundler,1.1.rc]
Open lib/language_pack/ruby.rb
in your editor, and change the following line:
BUNDLER_VERSION = "1.1.rc"
Open lib/language_pack/base.rb
in your editor, and change the following line:
VENDOR_URL = "https://s3.amazonaws.com/zzz"
Commit and push the changes to your buildpack to your Github fork, then push your sample app to Heroku to test. You should see:
-----> Installing dependencies using Bundler version 1.1.rc
NOTE: You'll need to vendor the plugins, node, Bundler, and libyaml by running the rake tasks for the buildpack to work properly.
$ git push heroku master
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.rc
Running: bundle install --without development:test --path vendor/bundle --deployment
...
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
-----> Rails plugin injection
Injecting rails_log_stdout
Injecting rails3_serve_static_assets
-----> Discovering process types
Procfile declares types -> web
Default types for Ruby/Rails -> console, rake, worker
The buildpack will detect your apps as a Rails 3 app if it has an application.rb
file in the config
directory.
Assets
To enable static assets being served on the dyno, rails3_serve_static_assets is installed by default. If the execjs gem is detected then node.js will be vendored. The assets:precompile
rake task will get run if no public/manifest.yml
is detected. See this article on how rails 3.1 works on cedar.
Hacking
To use this buildpack, fork it on Github. Push up changes to your fork, then create a test app with --buildpack <your-github-url>
and push to it.
To change the vendored binaries for Bundler, Node.js, and rails plugins, use the rake tasks provided by the Rakefile
. You'll need an S3-enabled AWS account and a bucket to store your binaries in as well as the vulcan gem to build the binaries on heroku.
For example, you can change the vendored version of Bundler to 1.1.rc.
First you'll need to build a Heroku-compatible version of Node.js:
$ export AWS_ID=xxx AWS_SECRET=yyy S3_BUCKET=zzz
$ s3 create $S3_BUCKET
$ rake gem:install[bundler,1.1.rc]
Open lib/language_pack/ruby.rb
in your editor, and change the following line:
BUNDLER_VERSION = "1.1.rc"
Open lib/language_pack/base.rb
in your editor, and change the following line:
VENDOR_URL = "https://s3.amazonaws.com/zzz"
Commit and push the changes to your buildpack to your Github fork, then push your sample app to Heroku to test. You should see:
-----> Installing dependencies using Bundler version 1.1.rc
NOTE: You'll need to vendor the plugins, node, Bundler, and libyaml by running the rake tasks for the buildpack to work properly.
ruby/master
Flow
The buildpack adds the octopress generate
task after rake assets:precompile
task in the Ruby language pack.
The Rack language pack is then invoked by the config.ru
file which runs the Sinatra Static Server to serve the generated files.
Rails 2/3 language packs remain in place but will be ignored.