recap 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/README.md +55 -10
- data/Rakefile +19 -5
- data/bin/recap +2 -2
- data/features/managing-processes.feature +1 -1
- data/features/setting-environment-variables.feature +26 -1
- data/features/steps/capistrano_steps.rb +10 -6
- data/features/support/project.rb +24 -5
- data/features/templates/project/Capfile.erb +1 -1
- data/lib/recap/recipes/rails.rb +6 -0
- data/lib/recap/recipes/ruby.rb +11 -0
- data/lib/recap/recipes/static.rb +3 -0
- data/lib/recap/recipes.rb +18 -0
- data/lib/recap/support/capistrano_extensions.rb +85 -0
- data/lib/recap/support/cli.rb +57 -0
- data/lib/recap/{compatibility.rb → support/compatibility.rb} +2 -2
- data/lib/recap/support/environment.rb +61 -0
- data/lib/recap/support/namespace.rb +47 -0
- data/lib/recap/support/shell_command.rb +35 -0
- data/lib/recap/support/templates/Capfile.erb +6 -0
- data/lib/recap/tasks/bootstrap.rb +77 -0
- data/lib/recap/{bundler.rb → tasks/bundler.rb} +15 -6
- data/lib/recap/{deploy.rb → tasks/deploy.rb} +30 -17
- data/lib/recap/tasks/env.rb +111 -0
- data/lib/recap/{foreman.rb → tasks/foreman.rb} +20 -12
- data/lib/recap/{preflight.rb → tasks/preflight.rb} +13 -11
- data/lib/recap/tasks/rails.rb +42 -0
- data/lib/recap/tasks.rb +16 -0
- data/lib/recap/version.rb +1 -1
- data/lib/recap.rb +119 -10
- data/recap.gemspec +3 -2
- data/spec/models/capistrano_extensions_spec.rb +41 -0
- data/spec/models/cli_spec.rb +25 -0
- data/spec/models/environment_spec.rb +14 -14
- data/spec/models/shell_command_spec.rb +55 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/tasks/bootstrap_spec.rb +9 -13
- data/spec/tasks/bundler_spec.rb +39 -7
- data/spec/tasks/deploy_spec.rb +42 -26
- data/spec/tasks/env_spec.rb +81 -5
- data/spec/tasks/foreman_spec.rb +10 -5
- data/spec/tasks/rails_spec.rb +80 -0
- metadata +65 -57
- data/doc/index.html +0 -235
- data/doc/lib/recap/bootstrap.html +0 -42
- data/doc/lib/recap/bundler.html +0 -168
- data/doc/lib/recap/capistrano_extensions.html +0 -208
- data/doc/lib/recap/cli.html +0 -42
- data/doc/lib/recap/compatibility.html +0 -73
- data/doc/lib/recap/deploy.html +0 -328
- data/doc/lib/recap/env.html +0 -108
- data/doc/lib/recap/foreman.html +0 -42
- data/doc/lib/recap/namespace.html +0 -42
- data/doc/lib/recap/preflight.html +0 -163
- data/doc/lib/recap/rails.html +0 -42
- data/doc/lib/recap/version.html +0 -42
- data/doc/lib/recap.html +0 -42
- data/index.rb +0 -62
- data/lib/recap/bootstrap.rb +0 -47
- data/lib/recap/capistrano_extensions.rb +0 -74
- data/lib/recap/cli.rb +0 -32
- data/lib/recap/deploy/templates/Capfile.erb +0 -6
- data/lib/recap/env.rb +0 -58
- data/lib/recap/environment.rb +0 -54
- data/lib/recap/namespace.rb +0 -37
- data/lib/recap/rails.rb +0 -24
- data/lib/recap/ruby.rb +0 -3
- data/lib/recap/static.rb +0 -1
data/doc/index.html
DELETED
@@ -1,235 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>index.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="index.html">index.rb</a>
|
16
|
-
<a class="source" href="lib/recap.html">recap.rb</a>
|
17
|
-
<a class="source" href="lib/recap/bootstrap.html">bootstrap.rb</a>
|
18
|
-
<a class="source" href="lib/recap/bundler.html">bundler.rb</a>
|
19
|
-
<a class="source" href="lib/recap/capistrano_extensions.html">capistrano_extensions.rb</a>
|
20
|
-
<a class="source" href="lib/recap/cli.html">cli.rb</a>
|
21
|
-
<a class="source" href="lib/recap/compatibility.html">compatibility.rb</a>
|
22
|
-
<a class="source" href="lib/recap/deploy.html">deploy.rb</a>
|
23
|
-
<a class="source" href="lib/recap/env.html">env.rb</a>
|
24
|
-
<a class="source" href="lib/recap/foreman.html">foreman.rb</a>
|
25
|
-
<a class="source" href="lib/recap/namespace.html">namespace.rb</a>
|
26
|
-
<a class="source" href="lib/recap/preflight.html">preflight.rb</a>
|
27
|
-
<a class="source" href="lib/recap/rails.html">rails.rb</a>
|
28
|
-
<a class="source" href="lib/recap/version.html">version.rb</a>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<table cellspacing=0 cellpadding=0>
|
33
|
-
<thead>
|
34
|
-
<tr>
|
35
|
-
<th class=docs><h1>index.rb</h1></th>
|
36
|
-
<th class=code></th>
|
37
|
-
</tr>
|
38
|
-
</thead>
|
39
|
-
<tbody>
|
40
|
-
<tr id='section-1'>
|
41
|
-
<td class=docs>
|
42
|
-
<div class="pilwrap">
|
43
|
-
<a class="pilcrow" href="#section-1">¶</a>
|
44
|
-
</div>
|
45
|
-
<p>This is the annotated source code and documentation for
|
46
|
-
<a href="http://github.com/freerange/recap">recap</a>, a simple, opinionated set of capistrano
|
47
|
-
deployment recipes. Inspired by
|
48
|
-
<a href="https://github.com/blog/470-deployment-script-spring-cleaning">this blog post</a>, these recipes use
|
49
|
-
git’s strengths to deploy applications in a faster, simpler manner than a standard capistrano
|
50
|
-
deployment. Using git to manage release versions means apps can be deployed to a single directory.
|
51
|
-
There’s no need for <code>releases</code>, <code>shared</code> or <code>current</code> folders, and no symlinking.</p>
|
52
|
-
</td>
|
53
|
-
<td class=code>
|
54
|
-
<div class='highlight'><pre></pre></div>
|
55
|
-
</td>
|
56
|
-
</tr>
|
57
|
-
<tr id='section-Goals'>
|
58
|
-
<td class=docs>
|
59
|
-
<div class="pilwrap">
|
60
|
-
<a class="pilcrow" href="#section-Goals">¶</a>
|
61
|
-
</div>
|
62
|
-
<h3>Goals</h3>
|
63
|
-
</td>
|
64
|
-
<td class=code>
|
65
|
-
<div class='highlight'><pre></pre></div>
|
66
|
-
</td>
|
67
|
-
</tr>
|
68
|
-
<tr id='section-3'>
|
69
|
-
<td class=docs>
|
70
|
-
<div class="pilwrap">
|
71
|
-
<a class="pilcrow" href="#section-3">¶</a>
|
72
|
-
</div>
|
73
|
-
<p>These deployment recipes try to do the following:</p>
|
74
|
-
</td>
|
75
|
-
<td class=code>
|
76
|
-
<div class='highlight'><pre></pre></div>
|
77
|
-
</td>
|
78
|
-
</tr>
|
79
|
-
<tr id='section-4'>
|
80
|
-
<td class=docs>
|
81
|
-
<div class="pilwrap">
|
82
|
-
<a class="pilcrow" href="#section-4">¶</a>
|
83
|
-
</div>
|
84
|
-
<p>Run all commands as the <code>application_user</code>, loading the full user environment. The only
|
85
|
-
exceptions are <code>git</code> commands (which often rely on SSH agent forwarding for authentication), and
|
86
|
-
anything that requires <code>sudo</code>.</p>
|
87
|
-
</td>
|
88
|
-
<td class=code>
|
89
|
-
<div class='highlight'><pre></pre></div>
|
90
|
-
</td>
|
91
|
-
</tr>
|
92
|
-
<tr id='section-5'>
|
93
|
-
<td class=docs>
|
94
|
-
<div class="pilwrap">
|
95
|
-
<a class="pilcrow" href="#section-5">¶</a>
|
96
|
-
</div>
|
97
|
-
<p>Use <code>git</code> to avoid unecessary work. If the <code>Gemfile.lock</code> hasn’t changed, there’s no need to run
|
98
|
-
<code>bundle install</code>. Similarly if there are no new migrations, why do <code>rake db:migrate</code>? Faster
|
99
|
-
deploys mean more frequent deploys.</p>
|
100
|
-
</td>
|
101
|
-
<td class=code>
|
102
|
-
<div class='highlight'><pre></pre></div>
|
103
|
-
</td>
|
104
|
-
</tr>
|
105
|
-
<tr id='section-6'>
|
106
|
-
<td class=docs>
|
107
|
-
<div class="pilwrap">
|
108
|
-
<a class="pilcrow" href="#section-6">¶</a>
|
109
|
-
</div>
|
110
|
-
<p>Avoid the use of <code>sudo</code> (other than to change to the <code>application_user</code>). As much as possible,
|
111
|
-
<code>sudo</code> is only used to <code>su</code> to the <code>application_user</code> before running a command. To avoid having to
|
112
|
-
type a password to perform the majority of deployment tasks, these lines can be added to
|
113
|
-
<code>/etc/sudoers.d/application</code> (change <code>application</code> to the name of your app).</p>
|
114
|
-
</td>
|
115
|
-
<td class=code>
|
116
|
-
<div class='highlight'><pre><span class="o">%</span><span class="n">application</span> <span class="no">ALL</span><span class="o">=</span><span class="no">NOPASSWD</span><span class="p">:</span><span class="sr"> /sbin/s</span><span class="n">tart</span> <span class="n">application</span><span class="o">*</span>
|
117
|
-
<span class="o">%</span><span class="n">application</span> <span class="no">ALL</span><span class="o">=</span><span class="no">NOPASSWD</span><span class="p">:</span><span class="sr"> /sbin/s</span><span class="n">top</span> <span class="n">application</span><span class="o">*</span>
|
118
|
-
<span class="o">%</span><span class="n">application</span> <span class="no">ALL</span><span class="o">=</span><span class="no">NOPASSWD</span><span class="p">:</span><span class="sr"> /sbin/</span><span class="n">restart</span> <span class="n">application</span><span class="o">*</span>
|
119
|
-
<span class="o">%</span><span class="n">application</span> <span class="no">ALL</span><span class="o">=</span><span class="no">NOPASSWD</span><span class="p">:</span><span class="sr"> /bin/su</span> <span class="o">-</span> <span class="n">application</span><span class="o">*</span>
|
120
|
-
<span class="o">%</span><span class="n">application</span> <span class="no">ALL</span><span class="o">=</span><span class="no">NOPASSWD</span><span class="p">:</span><span class="sr"> /bin/su</span> <span class="n">application</span><span class="o">*</span></pre></div>
|
121
|
-
</td>
|
122
|
-
</tr>
|
123
|
-
<tr id='section-7'>
|
124
|
-
<td class=docs>
|
125
|
-
<div class="pilwrap">
|
126
|
-
<a class="pilcrow" href="#section-7">¶</a>
|
127
|
-
</div>
|
128
|
-
<p>Use environment variables for configuration. Rather than setting <code>rails_env</code> in the <code>Capfile</code>,
|
129
|
-
<code>RAILS_ENV</code> (or <code>RACK_ENV</code>) variables should be set for the <code>application_user</code>. The <code>env:set</code> and
|
130
|
-
<code>env:edit</code> tasks help do this.</p>
|
131
|
-
</td>
|
132
|
-
<td class=code>
|
133
|
-
<div class='highlight'><pre></pre></div>
|
134
|
-
</td>
|
135
|
-
</tr>
|
136
|
-
<tr id='section-Code_layout'>
|
137
|
-
<td class=docs>
|
138
|
-
<div class="pilwrap">
|
139
|
-
<a class="pilcrow" href="#section-Code_layout">¶</a>
|
140
|
-
</div>
|
141
|
-
<h3>Code layout</h3>
|
142
|
-
</td>
|
143
|
-
<td class=code>
|
144
|
-
<div class='highlight'><pre></pre></div>
|
145
|
-
</td>
|
146
|
-
</tr>
|
147
|
-
<tr id='section-9'>
|
148
|
-
<td class=docs>
|
149
|
-
<div class="pilwrap">
|
150
|
-
<a class="pilcrow" href="#section-9">¶</a>
|
151
|
-
</div>
|
152
|
-
<p>The main deployment tasks are defined in <a href="lib/recap/deploy.html">recap/deploy.rb</a>. Automatic
|
153
|
-
checks to ensure servers are correctly setup are in
|
154
|
-
<a href="lib/recap/preflight.html">recap/preflight.rb</a>, while tasks for environment variables are in
|
155
|
-
<a href="lib/recap/env.html">recap/env.rb</a></p>
|
156
|
-
</td>
|
157
|
-
<td class=code>
|
158
|
-
<div class='highlight'><pre></pre></div>
|
159
|
-
</td>
|
160
|
-
</tr>
|
161
|
-
<tr id='section-10'>
|
162
|
-
<td class=docs>
|
163
|
-
<div class="pilwrap">
|
164
|
-
<a class="pilcrow" href="#section-10">¶</a>
|
165
|
-
</div>
|
166
|
-
<p>In addition, there are extensions for <a href="lib/recap/bundler.html">bundler</a>,
|
167
|
-
<a href="lib/recap/foreman.html">foreman</a> and <a href="lib/recap/rails.html">rails</a></p>
|
168
|
-
</td>
|
169
|
-
<td class=code>
|
170
|
-
<div class='highlight'><pre></pre></div>
|
171
|
-
</td>
|
172
|
-
</tr>
|
173
|
-
<tr id='section-11'>
|
174
|
-
<td class=docs>
|
175
|
-
<div class="pilwrap">
|
176
|
-
<a class="pilcrow" href="#section-11">¶</a>
|
177
|
-
</div>
|
178
|
-
<p>For limited compatability with other existing recipes, see
|
179
|
-
<a href="lib/recap/compatibility.html">compatibility</a>.</p>
|
180
|
-
</td>
|
181
|
-
<td class=code>
|
182
|
-
<div class='highlight'><pre></pre></div>
|
183
|
-
</td>
|
184
|
-
</tr>
|
185
|
-
<tr id='section-Deployment_target'>
|
186
|
-
<td class=docs>
|
187
|
-
<div class="pilwrap">
|
188
|
-
<a class="pilcrow" href="#section-Deployment_target">¶</a>
|
189
|
-
</div>
|
190
|
-
<h3>Deployment target</h3>
|
191
|
-
</td>
|
192
|
-
<td class=code>
|
193
|
-
<div class='highlight'><pre></pre></div>
|
194
|
-
</td>
|
195
|
-
</tr>
|
196
|
-
<tr id='section-13'>
|
197
|
-
<td class=docs>
|
198
|
-
<div class="pilwrap">
|
199
|
-
<a class="pilcrow" href="#section-13">¶</a>
|
200
|
-
</div>
|
201
|
-
<p>These recipes have been developed and tested using Ubuntu 11.04, though they may work well with
|
202
|
-
other flavours of unix.</p>
|
203
|
-
</td>
|
204
|
-
<td class=code>
|
205
|
-
<div class='highlight'><pre></pre></div>
|
206
|
-
</td>
|
207
|
-
</tr>
|
208
|
-
<tr id='section-14'>
|
209
|
-
<td class=docs>
|
210
|
-
<div class="pilwrap">
|
211
|
-
<a class="pilcrow" href="#section-14">¶</a>
|
212
|
-
</div>
|
213
|
-
<p>The application should be run as the application user; if using Apache and Passenger, you should
|
214
|
-
set the <code>PassengerDefaultUser</code> directive to be the same as the <code>application_user</code>.</p>
|
215
|
-
</td>
|
216
|
-
<td class=code>
|
217
|
-
<div class='highlight'><pre></pre></div>
|
218
|
-
</td>
|
219
|
-
</tr>
|
220
|
-
<tr id='section-15'>
|
221
|
-
<td class=docs>
|
222
|
-
<div class="pilwrap">
|
223
|
-
<a class="pilcrow" href="#section-15">¶</a>
|
224
|
-
</div>
|
225
|
-
<p>The code is available <a href="http://github.com/freerange/recap">on github</a> and released under the
|
226
|
-
<a href="https://github.com/freerange/recap/blob/master/LICENSE">MIT License</a></p>
|
227
|
-
|
228
|
-
</td>
|
229
|
-
<td class=code>
|
230
|
-
<div class='highlight'><pre></pre></div>
|
231
|
-
</td>
|
232
|
-
</tr>
|
233
|
-
</table>
|
234
|
-
</div>
|
235
|
-
</body>
|
@@ -1,42 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>bootstrap.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="../../index.html">index.rb</a>
|
16
|
-
<a class="source" href="../recap.html">recap.rb</a>
|
17
|
-
<a class="source" href="bootstrap.html">bootstrap.rb</a>
|
18
|
-
<a class="source" href="bundler.html">bundler.rb</a>
|
19
|
-
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
20
|
-
<a class="source" href="cli.html">cli.rb</a>
|
21
|
-
<a class="source" href="compatibility.html">compatibility.rb</a>
|
22
|
-
<a class="source" href="deploy.html">deploy.rb</a>
|
23
|
-
<a class="source" href="env.html">env.rb</a>
|
24
|
-
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
-
<a class="source" href="namespace.html">namespace.rb</a>
|
26
|
-
<a class="source" href="preflight.html">preflight.rb</a>
|
27
|
-
<a class="source" href="rails.html">rails.rb</a>
|
28
|
-
<a class="source" href="version.html">version.rb</a>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<table cellspacing=0 cellpadding=0>
|
33
|
-
<thead>
|
34
|
-
<tr>
|
35
|
-
<th class=docs><h1>bootstrap.rb</h1></th>
|
36
|
-
<th class=code></th>
|
37
|
-
</tr>
|
38
|
-
</thead>
|
39
|
-
<tbody>
|
40
|
-
</table>
|
41
|
-
</div>
|
42
|
-
</body>
|
data/doc/lib/recap/bundler.html
DELETED
@@ -1,168 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
5
|
-
<title>bundler.rb</title>
|
6
|
-
<link rel="stylesheet" href="http://jashkenas.github.com/docco/resources/docco.css">
|
7
|
-
</head>
|
8
|
-
<body>
|
9
|
-
<div id='container'>
|
10
|
-
<div id="background"></div>
|
11
|
-
<div id="jump_to">
|
12
|
-
Jump To …
|
13
|
-
<div id="jump_wrapper">
|
14
|
-
<div id="jump_page">
|
15
|
-
<a class="source" href="../../index.html">index.rb</a>
|
16
|
-
<a class="source" href="../recap.html">recap.rb</a>
|
17
|
-
<a class="source" href="bootstrap.html">bootstrap.rb</a>
|
18
|
-
<a class="source" href="bundler.html">bundler.rb</a>
|
19
|
-
<a class="source" href="capistrano_extensions.html">capistrano_extensions.rb</a>
|
20
|
-
<a class="source" href="cli.html">cli.rb</a>
|
21
|
-
<a class="source" href="compatibility.html">compatibility.rb</a>
|
22
|
-
<a class="source" href="deploy.html">deploy.rb</a>
|
23
|
-
<a class="source" href="env.html">env.rb</a>
|
24
|
-
<a class="source" href="foreman.html">foreman.rb</a>
|
25
|
-
<a class="source" href="namespace.html">namespace.rb</a>
|
26
|
-
<a class="source" href="preflight.html">preflight.rb</a>
|
27
|
-
<a class="source" href="rails.html">rails.rb</a>
|
28
|
-
<a class="source" href="version.html">version.rb</a>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<table cellspacing=0 cellpadding=0>
|
33
|
-
<thead>
|
34
|
-
<tr>
|
35
|
-
<th class=docs><h1>bundler.rb</h1></th>
|
36
|
-
<th class=code></th>
|
37
|
-
</tr>
|
38
|
-
</thead>
|
39
|
-
<tbody>
|
40
|
-
<tr id='section-1'>
|
41
|
-
<td class=docs>
|
42
|
-
<div class="pilwrap">
|
43
|
-
<a class="pilcrow" href="#section-1">¶</a>
|
44
|
-
</div>
|
45
|
-
<p>The bundler recipe ensures that the application bundle is installed whenever the code is updated.</p>
|
46
|
-
</td>
|
47
|
-
<td class=code>
|
48
|
-
<div class='highlight'><pre><span class="k">module</span> <span class="nn">Recap::Bundler</span>
|
49
|
-
<span class="kp">extend</span> <span class="no">Recap</span><span class="o">::</span><span class="no">Namespace</span>
|
50
|
-
|
51
|
-
<span class="n">namespace</span> <span class="ss">:bundle</span> <span class="k">do</span></pre></div>
|
52
|
-
</td>
|
53
|
-
</tr>
|
54
|
-
<tr id='section-2'>
|
55
|
-
<td class=docs>
|
56
|
-
<div class="pilwrap">
|
57
|
-
<a class="pilcrow" href="#section-2">¶</a>
|
58
|
-
</div>
|
59
|
-
<p>Each bundle is declared in a <code>Gemfile</code>, by default in the root of the application directory</p>
|
60
|
-
</td>
|
61
|
-
<td class=code>
|
62
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_gemfile</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"</span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">/Gemfile"</span> <span class="p">}</span></pre></div>
|
63
|
-
</td>
|
64
|
-
</tr>
|
65
|
-
<tr id='section-3'>
|
66
|
-
<td class=docs>
|
67
|
-
<div class="pilwrap">
|
68
|
-
<a class="pilcrow" href="#section-3">¶</a>
|
69
|
-
</div>
|
70
|
-
<p>As well as a <code>Gemfile</code>, application repositories should also contain a <code>Gemfile.lock</code>.</p>
|
71
|
-
</td>
|
72
|
-
<td class=code>
|
73
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_gemfile_lock</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"</span><span class="si">#{</span><span class="n">bundle_gemfile</span><span class="si">}</span><span class="s2">.lock"</span> <span class="p">}</span></pre></div>
|
74
|
-
</td>
|
75
|
-
</tr>
|
76
|
-
<tr id='section-4'>
|
77
|
-
<td class=docs>
|
78
|
-
<div class="pilwrap">
|
79
|
-
<a class="pilcrow" href="#section-4">¶</a>
|
80
|
-
</div>
|
81
|
-
<p>An application’s gems are installed within the application directory. By default they are
|
82
|
-
placed under <code>vendor/gems</code>.</p>
|
83
|
-
</td>
|
84
|
-
<td class=code>
|
85
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_path</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"</span><span class="si">#{</span><span class="n">deploy_to</span><span class="si">}</span><span class="s2">/vendor/gems"</span> <span class="p">}</span></pre></div>
|
86
|
-
</td>
|
87
|
-
</tr>
|
88
|
-
<tr id='section-5'>
|
89
|
-
<td class=docs>
|
90
|
-
<div class="pilwrap">
|
91
|
-
<a class="pilcrow" href="#section-5">¶</a>
|
92
|
-
</div>
|
93
|
-
<p>Not all gems are needed for production environments, so by default the <code>development</code>, <code>test</code> and
|
94
|
-
<code>assets</code> groups are skipped.</p>
|
95
|
-
</td>
|
96
|
-
<td class=code>
|
97
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_without</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"development test assets"</span> <span class="p">}</span></pre></div>
|
98
|
-
</td>
|
99
|
-
</tr>
|
100
|
-
<tr id='section-6'>
|
101
|
-
<td class=docs>
|
102
|
-
<div class="pilwrap">
|
103
|
-
<a class="pilcrow" href="#section-6">¶</a>
|
104
|
-
</div>
|
105
|
-
<p>The main bundle install command uses all the settings above, together with the <code>—deployment</code>,
|
106
|
-
<code>—binstubs</code> and <code>—quiet</code> flags</p>
|
107
|
-
</td>
|
108
|
-
<td class=code>
|
109
|
-
<div class='highlight'><pre> <span class="n">set</span><span class="p">(</span><span class="ss">:bundle_install_command</span><span class="p">)</span> <span class="p">{</span> <span class="s2">"bundle install --gemfile </span><span class="si">#{</span><span class="n">bundle_gemfile</span><span class="si">}</span><span class="s2"> --path </span><span class="si">#{</span><span class="n">bundle_path</span><span class="si">}</span><span class="s2"> --deployment --quiet --binstubs --without </span><span class="si">#{</span><span class="n">bundle_without</span><span class="si">}</span><span class="s2">"</span> <span class="p">}</span>
|
110
|
-
|
111
|
-
<span class="n">namespace</span> <span class="ss">:install</span> <span class="k">do</span></pre></div>
|
112
|
-
</td>
|
113
|
-
</tr>
|
114
|
-
<tr id='section-7'>
|
115
|
-
<td class=docs>
|
116
|
-
<div class="pilwrap">
|
117
|
-
<a class="pilcrow" href="#section-7">¶</a>
|
118
|
-
</div>
|
119
|
-
<p>After cloning or updating the code, we only install the bundle if the <code>Gemfile</code> has changed.</p>
|
120
|
-
</td>
|
121
|
-
<td class=code>
|
122
|
-
<div class='highlight'><pre> <span class="n">desc</span> <span class="s2">"Install the latest gem bundle only if Gemfile.lock has changed"</span>
|
123
|
-
<span class="n">task</span> <span class="ss">:if_changed</span> <span class="k">do</span>
|
124
|
-
<span class="k">if</span> <span class="n">deployed_file_changed?</span><span class="p">(</span><span class="n">bundle_gemfile_lock</span><span class="p">)</span>
|
125
|
-
<span class="n">top</span><span class="o">.</span><span class="n">bundle</span><span class="o">.</span><span class="n">install</span><span class="o">.</span><span class="n">default</span>
|
126
|
-
<span class="k">end</span>
|
127
|
-
<span class="k">end</span></pre></div>
|
128
|
-
</td>
|
129
|
-
</tr>
|
130
|
-
<tr id='section-8'>
|
131
|
-
<td class=docs>
|
132
|
-
<div class="pilwrap">
|
133
|
-
<a class="pilcrow" href="#section-8">¶</a>
|
134
|
-
</div>
|
135
|
-
<p>Occassionally it’s useful to force an install (such as if something has gone wrong in
|
136
|
-
a previous deployment)</p>
|
137
|
-
</td>
|
138
|
-
<td class=code>
|
139
|
-
<div class='highlight'><pre> <span class="n">desc</span> <span class="s2">"Install the latest gem bundle"</span>
|
140
|
-
<span class="n">task</span> <span class="ss">:default</span> <span class="k">do</span>
|
141
|
-
<span class="k">if</span> <span class="n">deployed_file_exists?</span><span class="p">(</span><span class="n">bundle_gemfile_lock</span><span class="p">)</span>
|
142
|
-
<span class="n">as_app</span> <span class="n">bundle_install_command</span>
|
143
|
-
<span class="k">else</span>
|
144
|
-
<span class="nb">puts</span> <span class="s2">"Skipping bundle:install as no Gemfile found"</span>
|
145
|
-
<span class="k">end</span>
|
146
|
-
<span class="k">end</span>
|
147
|
-
<span class="k">end</span></pre></div>
|
148
|
-
</td>
|
149
|
-
</tr>
|
150
|
-
<tr id='section-9'>
|
151
|
-
<td class=docs>
|
152
|
-
<div class="pilwrap">
|
153
|
-
<a class="pilcrow" href="#section-9">¶</a>
|
154
|
-
</div>
|
155
|
-
<p>To install the bundle automatically each time the code is updated or cloned, hooks are added to
|
156
|
-
the <code>deploy:clone_code</code> and <code>deploy:update_code</code> tasks.</p>
|
157
|
-
|
158
|
-
</td>
|
159
|
-
<td class=code>
|
160
|
-
<div class='highlight'><pre> <span class="n">after</span> <span class="s1">'deploy:clone_code'</span><span class="p">,</span> <span class="s1">'bundle:install:if_changed'</span>
|
161
|
-
<span class="n">after</span> <span class="s1">'deploy:update_code'</span><span class="p">,</span> <span class="s1">'bundle:install:if_changed'</span>
|
162
|
-
<span class="k">end</span>
|
163
|
-
<span class="k">end</span></pre></div>
|
164
|
-
</td>
|
165
|
-
</tr>
|
166
|
-
</table>
|
167
|
-
</div>
|
168
|
-
</body>
|