Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 167 lines (113 sloc) 6.806 kb
e23113a @hone update readme to new style
hone authored
1 Heroku buildpack: Ruby
2 ======================
9446500 @hone initial readme
hone authored
3
83b14d1 @oguzbilgic Fix heroku link on README
oguzbilgic authored
4 This is a [Heroku buildpack](http://devcenter.heroku.com/articles/buildpacks) for Ruby, Rack, and Rails apps. It uses [Bundler](http://gembundler.com) for dependency management.
9446500 @hone initial readme
hone authored
5
e23113a @hone update readme to new style
hone authored
6 Usage
7 -----
9446500 @hone initial readme
hone authored
8
e23113a @hone update readme to new style
hone authored
9 ### Ruby
9446500 @hone initial readme
hone authored
10
e23113a @hone update readme to new style
hone authored
11 Example Usage:
9446500 @hone initial readme
hone authored
12
e23113a @hone update readme to new style
hone authored
13 $ ls
14 Gemfile Gemfile.lock
9446500 @hone initial readme
hone authored
15
e23113a @hone update readme to new style
hone authored
16 $ heroku create --stack cedar --buildpack http://github.com/heroku/heroku-buildpack-ruby.git
9446500 @hone initial readme
hone authored
17
e23113a @hone update readme to new style
hone authored
18 $ git push heroku master
19 ...
20 -----> Heroku receiving push
21 -----> Fetching custom buildpack
22 -----> Ruby app detected
23 -----> Installing dependencies using Bundler version 1.1.rc
24 Running: bundle install --without development:test --path vendor/bundle --deployment
25 Fetching gem metadata from http://rubygems.org/..
26 Installing rack (1.3.5)
27 Using bundler (1.1.rc)
28 Your bundle is complete! It was installed into ./vendor/bundle
29 Cleaning up the bundler cache.
30 -----> Discovering process types
31 Procfile declares types -> (none)
32 Default types for Ruby -> console, rake
9446500 @hone initial readme
hone authored
33
b16333e @hone capitalize all instances of Bundler that aren't commands
hone authored
34 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](http://gembundler.com).
e23113a @hone update readme to new style
hone authored
35
36 #### Bundler
37
b16333e @hone capitalize all instances of Bundler that aren't commands
hone authored
38 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.
e23113a @hone update readme to new style
hone authored
39
40 ### Rails 2
41
42 Example Usage:
43
44 $ ls
45 app config db doc Gemfile Gemfile.lock lib log public Rakefile README script test tmp vendor
46
47 $ ls config/environment.rb
48 config/environment.rb
49
50 $ heroku create --stack cedar --buildpack http://github.com/heroku/heroku-buildpack-ruby.git
51
52 $ git push heroku master
53 ...
54 -----> Heroku receiving push
55 -----> Ruby/Rails app detected
56 -----> Installing dependencies using Bundler version 1.1.rc
57 ...
58 -----> Writing config/database.yml to read from DATABASE_URL
59 -----> Rails plugin injection
60 Injecting rails_log_stdout
61 -----> Discovering process types
62 Procfile declares types -> (none)
63 Default types for Ruby/Rails -> console, rake, web, worker
64
65 The buildpack will detect your app as a Rails 2 app if it has a `environment.rb` file in the `config` directory.
66
67 #### Rails Log STDOUT
68 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).
69
70 #### Auto Injecting Plugins
9446500 @hone initial readme
hone authored
71
72 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.
b3d2688 @hone add flow to readme
hone authored
73
e23113a @hone update readme to new style
hone authored
74 ### Rails 3
75
76 Example Usage:
77
78 $ ls
79 app config config.ru db doc Gemfile Gemfile.lock lib log Procfile public Rakefile README script tmp vendor
80
81 $ ls config/application.rb
82 config/application.rb
83
84 $ heroku create --stack cedar --buildpack http://github.com/heroku/heroku-buildpack-ruby.git
85
86 $ git push heroku master
87 -----> Heroku receiving push
88 -----> Ruby/Rails app detected
89 -----> Installing dependencies using Bundler version 1.1.rc
90 Running: bundle install --without development:test --path vendor/bundle --deployment
91 ...
92 -----> Writing config/database.yml to read from DATABASE_URL
93 -----> Preparing app for Rails asset pipeline
94 Running: rake assets:precompile
95 -----> Rails plugin injection
96 Injecting rails_log_stdout
97 Injecting rails3_serve_static_assets
98 -----> Discovering process types
99 Procfile declares types -> web
100 Default types for Ruby/Rails -> console, rake, worker
101
102 The buildpack will detect your apps as a Rails 3 app if it has an `application.rb` file in the `config` directory.
103
104 #### Assets
105
106 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.
b3d2688 @hone add flow to readme
hone authored
107
e23113a @hone update readme to new style
hone authored
108 Hacking
109 -------
110
111 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.
112
b16333e @hone capitalize all instances of Bundler that aren't commands
hone authored
113 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/ddollar/vulcan) gem to build the binaries on heroku.
e23113a @hone update readme to new style
hone authored
114
115 For example, you can change the vendored version of Bundler to 1.1.rc.
116
117 First you'll need to build a Heroku-compatible version of Node.js:
118
119 $ export AWS_ID=xxx AWS_SECRET=yyy S3_BUCKET=zzz
120 $ s3 create $S3_BUCKET
121 $ rake gem:install[bundler,1.1.rc]
122
123 Open `lib/language_pack/ruby.rb` in your editor, and change the following line:
124
125 BUNDLER_VERSION = "1.1.rc"
126
127 Open `lib/language_pack/base.rb` in your editor, and change the following line:
128
129 VENDOR_URL = "https://s3.amazonaws.com/zzz"
130
131 Commit and push the changes to your buildpack to your Github fork, then push your sample app to Heroku to test. You should see:
132
133 -----> Installing dependencies using Bundler version 1.1.rc
134
b16333e @hone capitalize all instances of Bundler that aren't commands
hone authored
135 NOTE: You'll need to vendor the plugins, node, Bundler, and libyaml by running the rake tasks for the buildpack to work properly.
e23113a @hone update readme to new style
hone authored
136
137 Flow
138 ----
139
140 Here's the basic flow of how the buildpack works:
b3d2688 @hone add flow to readme
hone authored
141
142 Ruby (Gemfile and Gemfile.lock is detected)
143
b16333e @hone capitalize all instances of Bundler that aren't commands
hone authored
144 * runs Bundler
b3d2688 @hone add flow to readme
hone authored
145 * installs binaries
04788ac @hone update readme
hone authored
146 * installs node if the gem execjs is detected
88b676e @hone update readme
hone authored
147 * runs `rake assets:precompile` if the rake task is detected
b3d2688 @hone add flow to readme
hone authored
148
2356972 @hone add section on rack
hone authored
149 Rack (config.ru is detected)
b3d2688 @hone add flow to readme
hone authored
150
151 * everything from Ruby
2356972 @hone add section on rack
hone authored
152 * sets RACK_ENV=production
153
154 Rails 2 (config/environment.rb is detected)
155
156 * everything from Rack
be605ae @hone show that rails 2 sets RAILS_ENV
hone authored
157 * sets RAILS_ENV=production
b3d2688 @hone add flow to readme
hone authored
158 * install rails 2 plugins
159 * [rails_log_stdout](http://github.com/ddollar/rails_log_stdout)
160
161 Rails 3 (config/application.rb is detected)
162
163 * everything from Rails 2
164 * install rails 3 plugins
165 * [rails3_server_static_assets](https://github.com/pedro/rails3_serve_static_assets)
662cc92 @hone add usage section to README
hone authored
166
Something went wrong with that request. Please try again.