Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: heroku/heroku-buildpack-ruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: mattmanning/heroku-buildpack-ruby-jekyll
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Nov 21, 2011

  1. Generate jekyll site

    mattmanning committed Nov 21, 2011
    Copy the full SHA
    e86ac4f View commit details

Commits on Nov 28, 2011

  1. Copy the full SHA
    96d1cfe View commit details

Commits on Dec 13, 2011

  1. Copy the full SHA
    c977f54 View commit details
  2. Copy the full SHA
    62c2ddd View commit details

Commits on Jan 18, 2012

  1. Copy the full SHA
    8e1f60c View commit details

Commits on Feb 19, 2012

  1. Copy the full SHA
    f012220 View commit details

Commits on Feb 20, 2012

  1. Merge pull request #1 from burkemw3/master

    Fail build if jekyll site generation fails
    mattmanning committed Feb 20, 2012
    Copy the full SHA
    5d5e699 View commit details
  2. Copy the full SHA
    d7a1ef2 View commit details

Commits on Mar 13, 2012

  1. Copy the full SHA
    ec0ceb3 View commit details
  2. Copy the full SHA
    1655b0a View commit details

Commits on Apr 19, 2012

  1. Copy the full SHA
    9d95a3c View commit details

Commits on Apr 30, 2012

  1. Copy the full SHA
    c1be6f1 View commit details

Commits on May 1, 2012

  1. Merge pull request #2 from lyoshenka/master

    Show Jekyll error output
    mattmanning committed May 1, 2012
    Copy the full SHA
    d23dae0 View commit details

Commits on May 12, 2012

  1. Copy the full SHA
    5c133eb View commit details

Commits on May 14, 2012

  1. Merge pull request #3 from burkemw3/master

    Add a more relevant README file
    mattmanning committed May 14, 2012
    Copy the full SHA
    4908a10 View commit details
  2. Copy the full SHA
    44ff7f5 View commit details
  3. Minor README edits.

    mattmanning committed May 14, 2012
    Copy the full SHA
    885290c View commit details

Commits on Jun 17, 2012

  1. Copy the full SHA
    74bb4d2 View commit details
  2. Copy the full SHA
    ee63730 View commit details

Commits on Jul 17, 2012

  1. Copy the full SHA
    6025285 View commit details

Commits on Aug 10, 2012

  1. Copy the full SHA
    774a46b View commit details
  2. Copy the full SHA
    33cc1d0 View commit details

Commits on Nov 1, 2012

  1. Merge upstream changes.

    mattmanning committed Nov 1, 2012
    Copy the full SHA
    c1a6bc8 View commit details

Commits on Nov 11, 2012

  1. Copy the full SHA
    65edc3a View commit details

Commits on Jan 22, 2013

  1. Merge pull request #4 from ssaunier/pipe-jekyll-compilation-output

    Pipe errors from jeyll compilation
    mattmanning committed Jan 22, 2013
    Copy the full SHA
    e285926 View commit details

Commits on Feb 9, 2013

  1. Fix merge.

    mattmanning committed Feb 9, 2013
    Copy the full SHA
    71330d1 View commit details

Commits on Mar 4, 2013

  1. Merge upstream changes.

    mattmanning committed Mar 4, 2013
    Copy the full SHA
    f9a2ae0 View commit details
  2. Copy the full SHA
    91b8140 View commit details
  3. Copy the full SHA
    256d69e View commit details
  4. More README updates.

    mattmanning committed Mar 4, 2013
    Copy the full SHA
    a4be7db View commit details

Commits on Oct 6, 2018

  1. fix upstream merge

    mattmanning committed Oct 6, 2018
    Copy the full SHA
    99b607c View commit details
  2. update jekyll command

    mattmanning committed Oct 6, 2018
    Copy the full SHA
    6a54030 View commit details
Showing with 61 additions and 163 deletions.
  1. +52 −163 README.md
  2. +9 −0 lib/language_pack/ruby.rb
215 changes: 52 additions & 163 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,174 +1,63 @@
# Heroku Buildpack for Ruby
![ruby](https://cloud.githubusercontent.com/assets/51578/13712725/3c6b3368-e793-11e5-83c1-728440111358.png)
Heroku Ruby Jekyll Buildpack
============================

This is a [Heroku Buildpack](http://devcenter.heroku.com/articles/buildpacks) for Ruby, Rack, and Rails apps. It uses [Bundler](https://bundler.io) for dependency management.
Heroku Ruby Jekyll Buildpack is a fork of Heroku's [official Ruby buildpack](https://github.com/heroku/heroku-buildpack-ruby) with added support for generating static [Jekyll](https://github.com/mojombo/jekyll) sites during the build/deployment stage.

This buildpack requires 64-bit Linux.
With this [buildpack](http://devcenter.heroku.com/articles/buildpacks) you no longer need pre-build the site or commit the _site build directory to your repo. This simplifies the deployment process and keeps the repo clean. All of the standard Ruby tools are maintained in this buildpack, so you can take full advantage of Rack middleware and other useful tools from the Ruby ecosystem.

## Usage

### Ruby

Example Usage:

$ ls
Gemfile Gemfile.lock

$ heroku create --buildpack https://github.com/heroku/heroku-buildpack-ruby.git
## Usage

$ git push heroku master
...
-----> Heroku receiving push
-----> Fetching custom buildpack
-----> Ruby app detected
-----> Installing dependencies using Bundler version 1.1.rc
Running: bundle install --without development:test --path vendor/bundle --deployment
Fetching gem metadata from http://rubygems.org/..
Installing rack (1.3.5)
Using bundler (1.1.rc)
heroku create --buildpack http://github.com/mattmanning/heroku-buildpack-ruby-jekyll.git

or add this buildpack to your current app

heroku config:add BUILDPACK_URL=http://github.com/mattmanning/heroku-buildpack-ruby-jekyll.git

Create a Ruby web app with dependencies managed by [Bundler](http://gembundler.com/) and a Jekyll site. [Heroku-Jekyll-Hello-World](https://github.com/burkemw3/Heroku-Jekyll-Hello-World) can be used as a sample starter.

git push heroku master

Watch it "Building jekyll site"

-----> Fetching custom git buildpack... done
-----> Ruby/Rack app detected
-----> Installing dependencies using Bundler version 1.3.0.pre.5
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Using posix-spawn (0.3.6)
Using albino (1.3.3)
Using fast-stemmer (1.0.0)
Using classifier (1.3.3)
Using daemons (1.1.4)
Using directory_watcher (1.4.1)
Using eventmachine (0.12.10)
Using kramdown (0.13.3)
Using liquid (2.3.0)
Using syntax (1.0.0)
Using maruku (0.6.0)
Using jekyll (0.11.0)
Using rack (1.3.5)
Using rack-contrib (1.1.0)
Using rack-rewrite (1.2.1)
Using thin (1.3.1)
Using bundler (1.3.0.pre.5)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
Would have removed bundler (1.2.1)
Building jekyll site
Configuration from /tmp/build_2khwpm40t8wev/_config.yml
Building site: . -> ./_site
Successfully generated site: . -> ./_site
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby -> console, rake

The buildpack will detect your app as Ruby if it has a `Gemfile` and `Gemfile.lock` files in the root directory. It will then proceed to run `bundle install` after setting up the appropriate environment for [ruby](http://ruby-lang.org) and [Bundler](https://bundler.io).

#### Bundler

For non-windows `Gemfile.lock` files, the `--deployment` flag will be used. In the case of windows, the Gemfile.lock will be deleted and Bundler will do a full resolve so native gems are handled properly. The `vendor/bundle` directory is cached between builds to allow for faster `bundle install` times. `bundle clean` is used to ensure no stale gems are stored between builds.

### Rails 2

Example Usage:

$ ls
app config db doc Gemfile Gemfile.lock lib log public Rakefile README script test tmp vendor

$ ls config/environment.rb
config/environment.rb

$ heroku create --buildpack https://github.com/heroku/heroku-buildpack-ruby.git

$ git push heroku master
...
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.1.rc
...
-----> Writing config/database.yml to read from DATABASE_URL
-----> Rails plugin injection
Injecting rails_log_stdout
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby/Rails -> console, rake, web, worker

The buildpack will detect your app as a Rails 2 app if it has a `environment.rb` file in the `config` directory.

#### Rails Log STDOUT
A [rails_log_stdout](http://github.com/ddollar/rails_log_stdout) is installed by default so Rails' logger will log to STDOUT and picked up by Heroku's [logplex](http://github.com/heroku/logplex).

#### Auto Injecting Plugins

Any vendored plugin can be stopped from being installed by creating the directory it's installed to in the slug. For instance, to prevent rails_log_stdout plugin from being injected, add `vendor/plugins/rails_log_stdout/.gitkeep` to your git repo.

### Rails 3

Example Usage:

$ ls
app config config.ru db doc Gemfile Gemfile.lock lib log Procfile public Rakefile README script tmp vendor

$ ls config/application.rb
config/application.rb

$ heroku create --buildpack https://github.com/heroku/heroku-buildpack-ruby.git

$ 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](http://github.com/pedro/rails3_serve_static_assets) is installed by default. If the [execjs gem](http://github.com/sstephenson/execjs) is detected then [node.js](http://github.com/joyent/node) will be vendored. The `assets:precompile` rake task will get run if no `public/manifest.yml` is detected. See [this article](http://devcenter.heroku.com/articles/rails31_heroku_cedar) on how rails 3.1 works on cedar.

## Documentation

For more information about using Ruby and buildpacks on Heroku, see these Dev Center articles:

- [Heroku Ruby Support](https://devcenter.heroku.com/articles/ruby-support)
- [Getting Started with Ruby on Heroku](https://devcenter.heroku.com/articles/getting-started-with-ruby)
- [Getting Started with Rails 4 on Heroku](https://devcenter.heroku.com/articles/getting-started-with-rails4)
- [Buildpacks](https://devcenter.heroku.com/articles/buildpacks)
- [Buildpack API](https://devcenter.heroku.com/articles/buildpack-api)

## 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](http://github.com/joyent/node), 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](http://github.com/heroku/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.11.2"

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.

### Testing

The tests on this buildpack are written in Rspec to allow the use of
`focused: true`. Parallelization of testing is provided by
https://github.com/grosser/parallel_tests this lib spins up an arbitrary
number of processes and running a different test file in each process,
it does not parallelize tests within a test file. To run the tests: clone the repo, then `bundle install` then clone the test fixtures by running:

```sh
$ bundle exec hatchet install
```

then go to [hatchet](https://github.com/heroku/hatchet) repo and follow the
instructions to set it up.

Now run the tests:

```sh
$ bundle exec parallel_rspec -n 6 spec/
```
Procfile declares types -> web
Default types for Ruby/Rack -> console, rake

If you don't want to run them in parallel you can still:
-----> Compiled slug size: 6.1MB
-----> Launching... done, v99
-----> Deploy hooks scheduled, check output in your logs
http://mattmanning.herokuapp.com deployed to Heroku

```sh
$ bundle exec rake spec
```
See Also
--------

Now go take a nap or do something for a really long time.
The blog post introducing this buildpack: [http://mwmanning.com/2011/11/29/Run-Your-Jekyll-Site-On-Heroku.html](http://mwmanning.com/2011/11/29/Run-Your-Jekyll-Site-On-Heroku.html).
9 changes: 9 additions & 0 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
@@ -107,6 +107,7 @@ def compile
create_database_yml
install_binaries
run_assets_precompile_rake_task
generate_jekyll_site
end
config_detect
best_practice_warnings
@@ -959,6 +960,14 @@ def run_assets_precompile_rake_task
end
end

def generate_jekyll_site
puts "Building jekyll site"
pipe("env PATH=$PATH bundle exec jekyll build 2>&1")
unless $? == 0
error "Failed to generate site with jekyll."
end
end

def precompile_fail(output)
mcount "fail.assets_precompile"
log "assets_precompile", :status => "failure"