pkgr 0.3.4 → 1.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.md +68 -463
  2. data/bin/pkgr +4 -52
  3. data/lib/pkgr.rb +13 -29
  4. data/lib/pkgr/app.rb +19 -4
  5. data/lib/pkgr/builder.rb +207 -0
  6. data/lib/pkgr/buildpack.rb +80 -0
  7. data/lib/pkgr/cli.rb +34 -158
  8. data/lib/pkgr/config.rb +65 -0
  9. data/lib/pkgr/data/distributions/debian/build_dependencies.yml +14 -0
  10. data/lib/pkgr/data/{debian → distributions/debian}/cron.d +0 -0
  11. data/lib/pkgr/data/distributions/debian/default.erb +12 -0
  12. data/lib/pkgr/data/distributions/debian/dependencies.yml +17 -0
  13. data/lib/pkgr/data/distributions/debian/hooks/postinstall.sh +27 -0
  14. data/lib/pkgr/data/distributions/debian/hooks/preinstall.sh +9 -0
  15. data/lib/pkgr/data/{debian → distributions/debian}/logrotate.erb +0 -0
  16. data/lib/pkgr/data/distributions/debian/runner.erb +122 -0
  17. data/lib/pkgr/data/distributions/debian/upstart/master.conf.erb +7 -0
  18. data/lib/pkgr/data/distributions/debian/upstart/process.conf.erb +7 -0
  19. data/lib/pkgr/data/distributions/debian/upstart/process_master.conf.erb +2 -0
  20. data/lib/pkgr/dispatcher.rb +51 -0
  21. data/lib/pkgr/distributions.rb +18 -0
  22. data/lib/pkgr/distributions/debian.rb +157 -0
  23. data/lib/pkgr/git.rb +24 -0
  24. data/lib/pkgr/process.rb +18 -0
  25. data/lib/pkgr/templates/dir_template.rb +14 -0
  26. data/lib/pkgr/templates/file_template.rb +38 -0
  27. data/lib/pkgr/version.rb +1 -1
  28. metadata +93 -26
  29. data/lib/pkgr/data/debian/changelog +0 -0
  30. data/lib/pkgr/data/debian/compat.erb +0 -1
  31. data/lib/pkgr/data/debian/control.erb +0 -12
  32. data/lib/pkgr/data/debian/copyright.erb +0 -17
  33. data/lib/pkgr/data/debian/default.erb +0 -11
  34. data/lib/pkgr/data/debian/dirs.erb +0 -2
  35. data/lib/pkgr/data/debian/docs.erb +0 -0
  36. data/lib/pkgr/data/debian/init.d.erb +0 -155
  37. data/lib/pkgr/data/debian/install.erb +0 -16
  38. data/lib/pkgr/data/debian/links.erb +0 -5
  39. data/lib/pkgr/data/debian/postinst.erb +0 -59
  40. data/lib/pkgr/data/debian/prerm.erb +0 -57
  41. data/lib/pkgr/data/debian/rules.erb +0 -7
  42. data/lib/pkgr/pkgr.rake +0 -50
  43. data/lib/pkgr/railtie.rb +0 -7
data/README.md CHANGED
@@ -1,498 +1,103 @@
1
1
  # pkgr
2
2
 
3
- Plug this [Railtie](http://api.rubyonrails.org/classes/Rails/Railtie.html)
4
- into your Rails 3 app (ruby1.9 only), and you'll be ready to package your
5
- Rails app as a DEB package. RPM support could/will be added in the short
6
- future.
3
+ ## Goal
7
4
 
8
- This gem originates from hours spent trying to figure out how to package a
9
- Ruby app for CentOS, and then Debian. It's definitely not trivial, because
10
- there are so many pieces to put together before getting something working.
11
- Hopefully this will save time for everyone :)
5
+ Make debian packages out of any app that can run on Heroku.
12
6
 
13
- Fair warning: there are probably a few things that could be done better, or in
14
- a more standard way. Feel free to open an issue and/or a pull-request.
7
+ ## Examples
15
8
 
16
- ## Why?
17
-
18
- [Capistrano](http://capify.org/) is great for deploying Rails/Ruby
19
- applications, but the deployment recipe can quickly become a mess, and scaling
20
- the deployment to more than a few servers can prove to be difficult. Plus, if
21
- you're already using automation tools such as
22
- [Puppet](http://www.puppetlabs.com/) to configure your servers, you have to
23
- run two different processes to configure your infrastructure.
24
-
25
- Another issue with Capistrano is that the hook system is not that powerful.
26
- Compare that with the pre/post-install/upgrade/uninstall steps that you can
27
- define in a RPM or DEB package, and you'll quickly see the advantage of
28
- letting a robust package manager such as `apt` or `yum` handle all those
29
- things for you in a reliable manner.
30
-
31
- Last thing, once you built your RPM or DEB package and you tested that it
32
- works once, you can deploy it on any number of servers at any time and you're
33
- sure that it will install the required package dependencies, run the hooks,
34
- and put the files in the directories you specified, creating them as needed.
35
- Then, you can downgrade or uninstall the whole application in one command.
36
-
37
- ## How?
38
-
39
- The issue with Ruby applications is that most of the gems are not (yet)
40
- packaged in the various Linux distributions. And even if they were, installing
41
- multiple Ruby applications that need two different versions of the same Ruby
42
- library would be impossible, since you can't install two different (minor)
43
- versions of a library with the package managers.
44
-
45
- So, how are we going to easily package Ruby applications and avoid dependency
46
- issues? Well, I know package maintainers will scream at me, but we'll just
47
- vendor the required gems in the package we'll build, and use bundler to manage
48
- those dependencies. Thus, the only dependency we'll put in our package will be
49
- Ruby1.9 (+rubygems).
50
-
51
- ## What?
52
-
53
- This gem will allow you to package your Rails3 application as a `.deb` package, and sets up a few things for you:
54
-
55
- * an `init.d` script to easily start/stop/restart your app, and make it load when the server boots;
56
-
57
- * an executable to manually start the server, your rake tasks, or access the console;
58
-
59
- * your configuration files will be available in `/etc/app-name/*.yml`;
60
-
61
- * defaults for your app (host, port, etc.) can be setup in `/etc/default/app-name`;
62
-
63
- * a proper `logrotate` file will be created for you, so that your log files
64
- don't eat all the disk space of your server;
65
-
66
- * and a few other things.
67
-
68
- The default target installation directory for all the other app files will be
69
- `/opt/local/app-name`. This can be configured.
70
-
71
- ## Requirements
72
-
73
- * You must use Rails3+ and ruby1.9+ in your application. This may work with
74
- other rubies but then you'll need to add adapt the dependencies.
75
-
76
- * Your Rails application must be able to run with the
77
- [`thin`](http://code.macournoyer.com/thin/) web server. Don't forget to add
78
- `thin` to your Gemfile!
79
-
80
- * Your Rails application must have a `config.ru` file.
81
-
82
- * Your application must be checked into a **Git** repository. Your name and
83
- email is taken from the git configuration, and the changelog is populated
84
- based on the git log between two versions.
85
-
86
- ## Getting started (quickly)
87
-
88
- Aka, how to build a debian package out of your Rails app in 5 minutes. This
89
- assumes that you have a VM or server running Debian Squeeze readily available
90
- for building the package.
91
-
92
- Install `pkgr`:
93
-
94
- $ gem install pkgr
95
-
96
- Create a new Rails app:
97
-
98
- $ rails new my-app
99
- create
100
- create README.rdoc
101
- create Rakefile
102
- ...
103
- create vendor/plugins
104
- create vendor/plugins/.gitkeep
105
-
106
- Initialize the git repository (if not already done):
107
-
108
- $ cd my-app
109
- $ git init
110
- $ git add .
111
- $ git commit -m "First commit"
112
-
113
- Package (this will create a new branch prefixed with `pkgr-`. You can delete
114
- it afterwards):
115
-
116
- $ pkgr --uri . --bump 0.1.0 --host debian-build-machine
117
- ...
118
- my-app_0.1.0-1_amd64.deb 100% 6080KB 5.9MB/s 00:01
119
-
120
- Your .deb package is in `pkg/my-app_0.1.0-1_amd64.deb`. Install it on your production server:
121
-
122
- $ scp pkg/my-app_0.1.0-1_amd64.deb production-machine:/tmp/
123
- $ ssh production-machine 'sudo dpkg -i /tmp/my-app_0.1.0-1_amd64.deb || sudo apt-get -f -y install'
124
-
125
- The app should now be up and running on `0.0.0.0:8000`. You might want to change this in the `/etc/default/my-app` file on the server.
126
-
127
- $ ssh production-machine 'curl -is localhost:8000'
128
-
129
- You should get a 404. This is expected since this app does nothing. You can
130
- now build your app and update the `config/pkgr.yml` file when you have system
131
- dependencies to add.
132
-
133
- Enjoy, and you may want to read the step-by-step guide to learn more about
134
- what's going on.
135
-
136
- ## Getting started (step by step)
137
-
138
- `pkgr` can be used as a command-line tool (fully automatic), or through the
139
- rake tasks it installs when you require it in your Gemfile. Below is how you would use the rake tasks to accomplish the same thing as before.
140
-
141
- ### Setup
142
-
143
- Create a new Rails app:
144
-
145
- $ rails new my-app --skip-bundle
146
- create
147
- create README.rdoc
148
- create Rakefile
149
- ...
150
- create vendor/plugins
151
- create vendor/plugins/.gitkeep
152
-
153
- Go into your app directory, and add `pkgr` to your Gemfile:
154
-
155
- $ cd my-app
156
- $ echo "gem 'pkgr'" >> Gemfile
157
-
158
- For now, this packaging tool only supports `thin` (would be easy to add others, though), so add it to your Gemfile:
159
-
160
- $ echo "gem 'thin'" >> Gemfile
161
-
162
- Install the gems:
163
-
164
- $ bundle install
165
-
166
- If it's not already done, initialize a git repository and create a first commit:
167
-
168
- $ git init
169
- $ git add .
170
- $ git commit -m "First commit"
171
-
172
- Setup `pkgr`:
173
-
174
- $ rake pkgr:setup
175
- Setting up configuration file...
176
- ...
177
- Edit '/Users/crohr/tmp/my-app/config/pkgr.yml' and fill in the required information, then enter 'rake pkgr:generate' to generate the debian files.
178
-
179
- As outlined, edit `config/pkgr.yml` and fill in your app name. In our example I'll fill in `my-app` as the app name. Also, you should edit the runtime and build dependencies (though the default ones should be fine with a base Rails app).
180
-
181
- An example `pkgr.yml` file is given below:
182
-
183
- ---
184
- version: 0.4.0
185
- name: my-app
186
- description: This is a description
187
- git_ref: HEAD
188
- config_files:
189
- - pkgr.yml
190
- - database.yml
191
- architecture: amd64
192
- debian_runtime_dependencies:
193
- - ${shlibs:Depends}
194
- - ${misc:Depends}
195
- - ruby1.9.1-full
196
- - git-core
197
- - libxml2
198
- - libxslt1.1
199
- debian_build_dependencies:
200
- - debhelper (>= 7)
201
- - dpkg-dev
202
- - libmysqlclient15-dev
203
- - libxml2-dev
204
- - libxslt-dev
205
- - libsqlite3-dev
206
-
207
- ### Generate the packaging files
208
-
209
- Now generate the required files for packaging:
210
-
211
- $ rake pkgr:generate
212
- mkdir -p /Users/crohr/tmp/my-app/debian
213
- cp /Users/crohr/.rvm/gems/ruby-1.9.3-p125/gems/pkgr-0.1.0/lib/pkgr/data/debian/changelog /Users/crohr/tmp/my-app/debian/changelog
214
- cp /Users/crohr/.rvm/gems/ruby-1.9.3-p125/gems/pkgr-0.1.0/lib/pkgr/data/debian/cron.d /Users/crohr/tmp/my-app/debian/cron.d
215
- Correctly set up debian files.
216
- mkdir -p /Users/crohr/tmp/my-app/bin
217
- cp /Users/crohr/.rvm/gems/ruby-1.9.3-p125/gems/pkgr-0.1.0/lib/pkgr/data/bin/executable /Users/crohr/tmp/my-app/bin/my-app
218
- chmod 755 /Users/crohr/tmp/my-app/bin/my-app
219
- Correctly set up executable file. Try running './bin/my-app console'.
220
-
221
- This will have created the required `debian/` files, plus an executable for your app, so that you're able to do the following:
9
+ * Gitlab package for debian wheezy: <http://deb.pkgr.io/crohr/gitlabhq/>.
222
10
 
223
- $ ./bin/my-app console development
224
- $ ./bin/my-app server start -e development
225
- $ ./bin/my-app rake some_task
11
+ ## Installation
226
12
 
227
- This is especially useful when the app is deployed on a server, since the executable will be added to the path!
13
+ Note: the new version of pkgr using buildpacks is only available as a pre-release.
228
14
 
229
- By default, you should not have to change anything in the `debian/` folder, so let's package our app.
15
+ Install `pkgr` on a Debian/Ubuntu machine (only `wheezy` flavour for now):
230
16
 
231
- ### Package the app
17
+ sudo apt-get install ruby1.9.1-full
18
+ sudo gem install pkgr --version "1.0.1.pre"
232
19
 
233
- First, make sure you committed all your changes:
20
+ ## Usage
234
21
 
235
- $ git add .
236
- $ git commit -m "..."
22
+ To package your app, you can either execute `pkgr` locally if your app repository is on the same machine:
237
23
 
238
- Then increase the version number:
24
+ pkgr path/to/app/repo
239
25
 
240
- $ rake pkgr:bump:minor
241
- Committing changelog and version file...
242
- git add debian/changelog /Users/crohr/tmp/my-app/config/pkgr.yml && git commit -m 'v0.1.0' debian/changelog /Users/crohr/tmp/my-app/config/pkgr.yml
243
- [master c05dd73] v0.1.0
244
- 2 files changed, 29 insertions(+), 31 deletions(-)
245
- rewrite config/pkgr.yml (82%)
246
- create mode 100755 debian/changelog
26
+ Or, assuming your build machine is accessible via SSH by doing `ssh pkgr-build-machine` (set this in your `~/.ssh/config` file), you can do as follows:
247
27
 
248
- Make sure you do not have any staged change (otherwise, commit them):
28
+ pkgr path/to/app/repo --host pkgr-build-machine
249
29
 
250
- $ git status
251
- # On branch master
252
- nothing to commit (working directory clean)
30
+ The resulting .deb package will be in your current working directory.
253
31
 
254
- Finally, ask to build the package on a machine running Debian Squeeze (I generally use my SSH config file to handle the SSH connection details for the specified host):
32
+ Full command line options are given below:
255
33
 
256
- $ HOST=debian-build-machine rake pkgr:build:deb
34
+ $ pkgr help package
35
+ Usage:
36
+ pkgr package TARBALL
257
37
 
258
- After some time, you should get a final line with the name of your debian package:
38
+ Options:
39
+ [--target=TARGET] # Target package to build (only 'deb' supported for now)
40
+ # Default: deb
41
+ [--changelog=CHANGELOG] # Changelog
42
+ [--architecture=ARCHITECTURE] # Target architecture for the package
43
+ # Default: x86_64
44
+ [--homepage=HOMEPAGE] # Project homepage
45
+ [--description=DESCRIPTION] # Project description
46
+ [--version=VERSION] # Package version (if git directory given, it will use the latest git tag available)
47
+ [--iteration=ITERATION] # Package iteration (you should keep the default here)
48
+ # Default: 20131007132226
49
+ [--user=USER] # User to run the app under (defaults to your app name)
50
+ [--group=GROUP] # Group to run the app under (defaults to your app name)
51
+ [--compile-cache-dir=COMPILE_CACHE_DIR] # Where to store the files cached between packaging runs
52
+ [--dependencies=one two three] # Specific system dependencies that you want to install with the package
53
+ [--build-dependencies=one two three] # Specific system dependencies that must be present before building
54
+ [--before-precompile=BEFORE_PRECOMPILE] # Provide a script to run just before the buildpack compilation
55
+ [--host=HOST] # Remote host to build on (default: local machine)
56
+ [--auto] # Automatically attempt to install missing dependencies
57
+ [--verbose] # Run verbosely
58
+ [--debug] # Run very verbosely
59
+ [--name=NAME] # Application name (if directory given, it will default to the directory name)
259
60
 
260
- [... lots of lines ...]
261
- my-app_0.1.0-1_amd64.deb
262
-
263
- Make sure it is really here:
264
-
265
- $ ls -l pkg/
266
- total 12128
267
- -rw-r--r-- 1 crohr staff 6207392 May 4 10:57 my-app_0.1.0-1_amd64.deb
268
-
269
- ### Use it
270
-
271
- Now you can either upload it to an apt repository (if you have one, I'll make a tutorial on how to set up a simple one), or just test that the package works by installing it on your build machine (or another one, for that matter, but you'll have to manually re-install the dependencies):
272
-
273
- $ scp pkg/my-app_0.1.0-1_amd64.deb debian-build-machine:/tmp/
274
- $ ssh debian-build-machine
275
- debian-build-machine $ sudo dpkg -i /tmp/my-app_0.1.0-1_amd64.deb
276
- Selecting previously deselected package my-app.
277
- (Reading database ... 53073 files and directories currently installed.)
278
- Unpacking my-app (from /tmp/my-app_0.1.0-1_amd64.deb) ...
279
- Setting up my-app (0.1.0-1) ...
280
- Installing new version of config file /etc/my-app/pkgr.yml ...
281
- Adding system user `my-app' (UID 105) ...
282
- Adding new group `my-app' (GID 108) ...
283
- Adding new user `my-app' (UID 105) with group `my-app' ...
284
- Not creating home directory `/home/my-app'.
285
- Starting my-app: OK.
286
-
287
- Make sure your app is running:
288
-
289
- debian-build-machine $ ps aux | grep my-app | grep -v grep
290
- my-app 13928 3.5 10.5 143436 40004 ? Sl 11:06 0:02 thin server (0.0.0.0:8000) [my-app-0.1.0]
291
-
292
- Notice how the process name shows the version number? From experience, this is really useful.
293
-
294
- Now you can send a first request:
295
-
296
- $ curl localhost:8000/
297
- <!DOCTYPE html>
298
- <html>
299
- <head>
300
- <title>The page you were looking for doesn't exist (404)</title>
301
- <style type="text/css">
302
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
303
- div.dialog {
304
- width: 25em;
305
- padding: 0 4em;
306
- margin: 4em auto 0 auto;
307
- border: 1px solid #ccc;
308
- border-right-color: #999;
309
- border-bottom-color: #999;
310
- }
311
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
312
- </style>
313
- </head>
314
-
315
- <body>
316
- <!-- This file lives in public/404.html -->
317
- <div class="dialog">
318
- <h1>The page you were looking for doesn't exist.</h1>
319
- <p>You may have mistyped the address or the page may have moved.</p>
320
- </div>
321
- </body>
322
- </html>
323
-
324
- Obviously this app does nothing, so you'll get a 404. So go back to building your app, and then just type `rake pkgr:bump:patch` and `HOST=debian-build-machine rake pkgr:build:deb` to generate a new package !
325
-
326
- ### Release it (debian)
327
-
328
- As of 0.2.0, you can now release the latest package on a server, and add it to
329
- your list of APT sources for easy installation. In the following we'll assume
330
- that you want to serve your packages from a host called `apt-server`.
331
-
332
- Once you've built the package, run the following to upload it to the
333
- apt-server and generate the manifest:
334
-
335
- $ HOST=apt-server rake pkgr:release:deb
336
-
337
- Note that you need **sudo** privileges for this. If all goes well, you should
338
- now have a directory named `/var/www/my-app` on `apt-server`. The next step is
339
- to serve this directory over HTTP. Simply enough, install `apache2` and you're
340
- good to go:
341
-
342
- $ ssh apt-server 'sudo apt-get install apache2 -y'
343
-
344
- Now, on the server on which you want to install the package (let's say
345
- `production-server`), just add an additional APT source file referencing this
346
- new APT server:
347
-
348
-
349
- production-server # cat /etc/apt/sources.list.d/my-app.list
350
- deb http://apt-server.ltd/my-app /
351
-
352
- And then:
353
-
354
- production-server # apt-get update && apt-get install my-app
355
-
356
- Note that you may need to add the following to a
357
- `/etc/apt/apt.conf.d/allow-unauthenticated` file if apt complains about
358
- unauthenticated packages:
359
-
360
- production-server # echo 'APT::Get::AllowUnauthenticated "true";' >> /etc/apt/apt.conf.d/allow-unauthenticated
361
-
362
- ## General usage
363
-
364
- Declare `pkgr` as one of your dependencies in your `Gemfile`:
365
-
366
- gem 'pkgr'
367
-
368
- Also add `thin`:
369
-
370
- gem 'thin'
371
-
372
- Now make sure you have all the gems installed:
373
-
374
- bundle install
375
-
376
- `pkgr` will install a number of new rake tasks to handle the packaging
377
- workflow. But first, you'll have to create a configuration file to get it
378
- working:
379
-
380
- rake pkgr:setup
381
-
382
- This will create a configuration file at `config/pkgr.yml`. Edit it, and fill
383
- in details about the `name` of your application, description, and the list of
384
- runtime dependencies it depends on. Same for dependencies required at build
385
- time only (most of the time, development headers).
386
-
387
- Now you can generate all the files required for building a debian package:
388
-
389
- rake pkgr:generate
390
-
391
- A new directory `debian/` should have been created. You can have a look at it,
392
- but you should not have to edit anything manually.
393
-
394
- Once you're ready to package your app, just run the following commands:
395
-
396
- * Commit your changes (the `pkgr` app will `git archive HEAD`, which means all
397
- your changes must be committed first -- we may want to change this):
398
-
399
- commit -am "..."
400
-
401
- * Increment the version number:
402
-
403
- rake pkgr:bump:patch # or rake pkgr:bump:minor or rake pkgr:bump:major
404
-
405
- * Build the package on your machine (default, but you better be running a
406
- Debian Squeeze, and have an SSH server running), or on a remote machine
407
- (recommended, for instance you can get a Vagrant VM in no time):
408
-
409
- HOST=debian-build-machine rake pkgr:build:deb
410
- # or HOST=localhost rake pkgr:build:deb, or just rake pkgr:build:deb
411
-
412
- Note that the user with which you're connecting to the build machine **must
413
- have `sudo` privileges** (required to install build and runtime
414
- dependencies).
415
-
416
- Also, it's most likely that you'll have to do this a few times at first, as
417
- well as adding missing runtime and build dependencies, before your app can
418
- be successfully packaged.
419
-
420
- * Your .deb package should be made available in the `pkg` directory of your
421
- app. Next step is probably to upload it to a local apt repository, and then
422
- a simple `apt-get install my-app` will install everything. Enjoy!
423
-
424
- ## CLI usage
425
-
426
- Starting from version 0.3.0, pkgr now comes with an executable, which allows
427
- to package any app stored in a git repository with one command.
428
-
429
- For instance, here is how you would package the [Redmine] [redmine] app:
430
-
431
- $ cd /tmp
432
- $ pkgr --uri https://github.com/edavis10/redmine --ref master --bump 1.4.1 \
433
- -c https://raw.github.com/crohr/pkgr/master/examples/redmine/configuration.yml \
434
- -c https://raw.github.com/crohr/pkgr/master/examples/redmine/database.yml \
435
- -c https://raw.github.com/crohr/pkgr/master/examples/redmine/pkgr.yml \
436
- --host debian-build
437
-
438
- You .deb package will be available in `/tmp/redmine/pkg/`. In this example,
439
- the given `pkgr.yml` configuration file automatically adds a dependency on
440
- `mysql-server`, which means that when you install the generated redmine
441
- package, it will be ready to be accessed on `0.0.0.0:8000`.
442
-
443
- Note that for simple projects, you may not need to specify all those
444
- configuration files on the command line. Redmine is a complex app.
445
-
446
- See `pkgr -h` for the list of options available:
447
-
448
- $ pkgr -h
449
- * Description
450
- pkgr 0.2.0 - Package Rails apps effortlessly.
451
- * Usage
452
- pkgr --uri GIT_REPOSITORY --config database.yml:http://path/to/database.yml --config ...
453
-
454
- * Common options
455
- --uri= Sets the Git repository URI (FILE, HTTP, SSH, GIT, etc.) [required]
456
- -c, --config= Download a configuration file into the config/ folder of the app (HTTP or FILE URIs)
457
- -b, --bump= Sets the app version [required]
458
- -n, --name= Sets the app name [optional]
459
- --ref= Sets the git reference to checkout [default=master]
460
- --host= Sets the build machine hostname. If none, the process will stop just before building the package.
461
-
462
- * Other
463
- -h, --help Show this message
464
- --version Show version
465
-
466
- [redmine]: http://www.redmine.org/
467
-
468
- ## Notes of interest
61
+ ## Why?
469
62
 
470
- * your configuration files will be stored in `/etc/my-app/*.yml`, making it easy to manage with Puppet or manually (don't forget to `/etc/init.d/my-app restart` after making changes).
63
+ [Capistrano](http://capify.org/) is great for deploying Rails/Ruby
64
+ applications, but the deployment recipe can quickly become a mess, and scaling
65
+ the deployment to more than a few servers can prove to be difficult. Plus, if
66
+ you're already using automation tools such as
67
+ [Puppet](http://www.puppetlabs.com/) to configure your servers, you have to
68
+ run two different processes to configure your infrastructure.
471
69
 
472
- * you can change how the Thin server is launched by adding options to the `/etc/default/my-app` file.
70
+ Also, once you built your DEB package and you tested that it
71
+ works once, you can deploy it on any number of servers at any time and you're
72
+ sure that it will install the required package dependencies, run the hooks,
73
+ and put the files in the directories you specified, creating them as needed.
74
+ Then, you can downgrade or uninstall the whole application in one command.
473
75
 
474
- * your log files will be stored in `/var/log/my-app/`.
76
+ ## What this does
475
77
 
476
- * your db files will be stored in `var/db/my-app/`.
78
+ * Uses Heroku buildpacks to embed all your dependencies within the debian package. That way, no need to mess with stale system dependencies, and no need to install anything by hand. Also, we get for free all the hard work done by Heroku developers to make sure your app runs fine in an isolated way.
477
79
 
478
- * if you've got migrations to run, just do a `my-app rake db:migrate` (we might want to run them automatically as part of the postinstall process).
80
+ * Gives you a nice executable, which closely replicates the Heroku toolbelt utility. For instance, assuming you're packaging an app called `my-app`, you can do the following:
479
81
 
480
- * you can launch a console using `my-app console`.
82
+ my-app config:set VAR=value
83
+ my-app config:get VAR
84
+ my-app run [procfile process]
85
+ my-app scale web=1 worker=1
86
+ ...
481
87
 
482
- * use the initd script to start and stop the app: `/etc/init.d/my-app [start|stop|restart|status]`.
88
+ * You app will reside in `/opt/app-name`.
483
89
 
484
- ## Todo
90
+ * You'll also get a upstart based initialization script that you can use directly.
485
91
 
486
- * Speed up the packaging process (currently, bundler re-downloads all the gems
487
- each time you package an app).
92
+ * Logs will be stored in `/var/log/app-name/`, with a proper logrotate config automatically added.
488
93
 
489
- * Include tasks for building RPMs.
94
+ * Config files can be added in `/etc/app-name/`
490
95
 
491
- * The included initd script sucks. Improve it.
96
+ ## Requirements
492
97
 
493
- * Populate system dependencies based on gems declared in the Gemfile.
98
+ * You must have a Procfile.
494
99
 
495
- * Some tests.
100
+ * Your application must be Heroku compatible, meaning you should be able to set your main app's configuration via environment variables.
496
101
 
497
102
  ## Authors
498
103