ruby_yacht 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rdoc_options +1 -0
- data/.yardopts +4 -0
- data/README.md +11 -3
- data/doc/TODO.md +2 -0
- data/doc/configuration.md +301 -0
- data/doc/configuration_sample.rb +8 -6
- data/doc/{CONTRIBUTING.md → contributing.md} +1 -1
- data/doc/plugins.md +230 -0
- data/lib/ruby_yacht/dsl/database.rb +1 -1
- data/lib/ruby_yacht/dsl/hook.rb +1 -0
- data/ruby_yacht.gemspec +2 -2
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 724d4833d4fccb763b4173463fd4d39a6c72b5af
|
4
|
+
data.tar.gz: 385d64ac428190fe57096eeb5382f03fd3de4099
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3acb66557ac774872c8548f5afc9bb3e9a0e5fa5b189e5c2846e19eed7e3afbe1f7ee3b7345140ace4ae838d5b2315f538a53745219896f7ee94a06b1c9f35d1
|
7
|
+
data.tar.gz: fad7d2289310ee0c3ffed0f02250d1c86060bdf0f64ea3c1190c343eaa05a965595e2b15aa3fdd54807f458303244807235d1aceae57031f449cc7578ff519f9
|
data/.gitignore
CHANGED
data/.rdoc_options
CHANGED
data/.yardopts
ADDED
data/README.md
CHANGED
@@ -27,8 +27,8 @@ Enter this in the file:
|
|
27
27
|
|
28
28
|
Your `run.rb` file will have two parts: A configuration block and the `Runner`
|
29
29
|
command. The configuration block defines your projects and your apps. You can
|
30
|
-
read [
|
31
|
-
for more information on
|
30
|
+
read [the configuration documentation](/gems/ruby_yacht/file/doc/configuration.md)
|
31
|
+
for more information on the configuration options.
|
32
32
|
|
33
33
|
The runner command invokes a RubyYacht script based on the command information.
|
34
34
|
|
@@ -210,8 +210,16 @@ branch.
|
|
210
210
|
If you run it for a branch that you already have checked out, it will pull down
|
211
211
|
the latest changes from the repository.
|
212
212
|
|
213
|
+
# Plugins and Customization
|
214
|
+
|
215
|
+
RubyYacht has a [plugin API](/gems/ruby_yacht/file/doc/plugins.md) for
|
216
|
+
customizing the behavior of your scripts. You can use plugins for defining new
|
217
|
+
app types or database types, or for adding hooks for the built-in types. This
|
218
|
+
plugin API is so powerful that all of the rails-specific and mysql-specific code
|
219
|
+
in RubyYacht is provided through plugins.
|
220
|
+
|
213
221
|
# Additional Information
|
214
222
|
|
215
223
|
If you're interested in contributing to the project, you can find more
|
216
|
-
information in [
|
224
|
+
information in [the contributing documentation](/gems/ruby_yacht/file/doc/contributing.md).
|
217
225
|
You can also reach out to me on Twitter [@brownleej](https://twitter.com/brownleej)
|
data/doc/TODO.md
CHANGED
@@ -8,11 +8,13 @@ for open tickets.
|
|
8
8
|
approach
|
9
9
|
* Look into issues with running shell command that has its own command-line
|
10
10
|
flags.
|
11
|
+
* Create shorthands for loading config from external files.
|
11
12
|
|
12
13
|
# Plugins
|
13
14
|
|
14
15
|
* Better support for rails apps with no database
|
15
16
|
* Configurable ports for database servers
|
17
|
+
* Support for SQLite databases
|
16
18
|
|
17
19
|
# More customization
|
18
20
|
|
@@ -0,0 +1,301 @@
|
|
1
|
+
# Configuring RubyYacht
|
2
|
+
|
3
|
+
All configuration in RubyYacht is done through a `RubyYacht.configure` block.
|
4
|
+
This block allows you to run methods against `RubyYacht::Configuration::DSL` to
|
5
|
+
add projects and define hooks. Once the block is done, all the changes are added
|
6
|
+
into the shared `RubyYacht.configuration` object. You can run arbitrary code
|
7
|
+
inside this block, but take note that the `RubyYacht.configuration` object will
|
8
|
+
not be updated inside this block.
|
9
|
+
|
10
|
+
# Example
|
11
|
+
|
12
|
+
You can see [configuration_sample.rb](https://github.com/brownleej/ruby-yacht/blob/master/doc/configuration_sample.rb)
|
13
|
+
for an example of what a full configuration file would look like.
|
14
|
+
|
15
|
+
# Adding Projects
|
16
|
+
|
17
|
+
Inside a `configure` block, you can call `project :apollo` to add a project
|
18
|
+
named `apollo`. The `project` method takes a block, which allows you to run
|
19
|
+
methods against `RubyYacht::Project::DSL` to fill in the details of your
|
20
|
+
project.
|
21
|
+
|
22
|
+
### Project Fields
|
23
|
+
|
24
|
+
You can provide the following fields.
|
25
|
+
|
26
|
+
<table>
|
27
|
+
<tr>
|
28
|
+
<th>Name</th>
|
29
|
+
<th>Description</th>
|
30
|
+
<th>Example</th>
|
31
|
+
<th>Default</th>
|
32
|
+
</tr>
|
33
|
+
<tr>
|
34
|
+
<td>system_prefix</td>
|
35
|
+
<td>
|
36
|
+
The prefix that is prepended before the names of the images and containers
|
37
|
+
for this project.
|
38
|
+
</td>
|
39
|
+
<td><code>system_prefix :foo</code></td>
|
40
|
+
<td>None; this is required.</td>
|
41
|
+
</tr>
|
42
|
+
<tr>
|
43
|
+
<td>domain</td>
|
44
|
+
<td>
|
45
|
+
The main domain for this project. Different apps will be added as
|
46
|
+
subdomains of this main domain.
|
47
|
+
</td>
|
48
|
+
<td><code>domain 'test.com'</code></td>
|
49
|
+
<td>None; this is required.</td>
|
50
|
+
</tr>
|
51
|
+
<tr>
|
52
|
+
<td>repository</td>
|
53
|
+
<td>
|
54
|
+
The host name for the code repository that holds the apps.
|
55
|
+
</td>
|
56
|
+
<td><code>repository 'github.com'</code></td>
|
57
|
+
<td>None; this is required.</td>
|
58
|
+
</tr>
|
59
|
+
<tr>
|
60
|
+
<td>check_out_locally</td>
|
61
|
+
<td>
|
62
|
+
Whether we should check out the code on the host system and map that
|
63
|
+
directory into the docker container. If this is set to false, the code
|
64
|
+
will not be easily accessible from the host system.
|
65
|
+
</td>
|
66
|
+
<td>
|
67
|
+
<code>check_out_locally # If you want to set it to true.</code>
|
68
|
+
</td>
|
69
|
+
<td>
|
70
|
+
False
|
71
|
+
</td>
|
72
|
+
</tr>
|
73
|
+
<tr>
|
74
|
+
<td>primary_app</td>
|
75
|
+
<td>
|
76
|
+
The name of the primary app that should be served from the main domain.
|
77
|
+
If this is nil, then the main domain will server a landing
|
78
|
+
page with a list of the apps, and the apps themselves will be accessed
|
79
|
+
through subdomains.
|
80
|
+
</td>
|
81
|
+
<td>
|
82
|
+
<code>primary_app :mars</code>
|
83
|
+
</td>
|
84
|
+
<td>
|
85
|
+
nil
|
86
|
+
</td>
|
87
|
+
</tr>
|
88
|
+
</table>
|
89
|
+
|
90
|
+
Inside a project block, you also define databases, DNS servers, and apps, as
|
91
|
+
described below.
|
92
|
+
|
93
|
+
### Plugin-Specific Fields
|
94
|
+
|
95
|
+
If you have loaded the Rails plugin, which is loaded by default, the project
|
96
|
+
will also have the following fields:
|
97
|
+
|
98
|
+
|
99
|
+
<table>
|
100
|
+
<tr>
|
101
|
+
<th>Name</th>
|
102
|
+
<th>Description</th>
|
103
|
+
<th>Example</th>
|
104
|
+
<th>Default</th>
|
105
|
+
</tr>
|
106
|
+
<tr>
|
107
|
+
<td>rails_environment</td>
|
108
|
+
<td>
|
109
|
+
The environment for the Rails apps.
|
110
|
+
</td>
|
111
|
+
<td><code>rails_environment 'development'</code></td>
|
112
|
+
<td>development</td>
|
113
|
+
</tr>
|
114
|
+
<tr>
|
115
|
+
<td>rails_secret_key_base</td>
|
116
|
+
<td>
|
117
|
+
<p>
|
118
|
+
The key for signing sessions and other app secrets in the Rails apps.
|
119
|
+
</p>
|
120
|
+
<p>
|
121
|
+
You will probably want to keep this outside of your configuration
|
122
|
+
scripts and outside of source control, so that it is kept secure and can
|
123
|
+
be set to different values in different environments.
|
124
|
+
</p>
|
125
|
+
</td>
|
126
|
+
<td><code>rails_secret_key_base 'abc123'</code></td>
|
127
|
+
<td>None; this is required</td>
|
128
|
+
</tr>
|
129
|
+
</table>
|
130
|
+
|
131
|
+
For more information about working with the default plugins, see
|
132
|
+
[Default Plugins](#Default_Plugins) below.
|
133
|
+
|
134
|
+
# Adding Apps
|
135
|
+
|
136
|
+
Inside the project DSL, you can call `app :mars, :rails` to add a Rails app
|
137
|
+
called `mars`. You can also call `rails_app :mars` to do the same thing. Both
|
138
|
+
forms take a block, which allows you to call methods from `RubyYacht::App::DSL`.
|
139
|
+
|
140
|
+
If you are using a different app type, you can supply that type instead of
|
141
|
+
`rails`, but the app type must be defined through a [plugin](/gems/ruby_yacht/file/doc/plugins.md).
|
142
|
+
|
143
|
+
You can call the `app` method multiple times to add multiple databases.
|
144
|
+
|
145
|
+
### App Fields
|
146
|
+
|
147
|
+
You can provide the following fields in the app DSL:
|
148
|
+
|
149
|
+
<table>
|
150
|
+
<tr>
|
151
|
+
<th>Name</th>
|
152
|
+
<th>Description</th>
|
153
|
+
<th>Example</th>
|
154
|
+
<td>Default</td>
|
155
|
+
</tr>
|
156
|
+
<tr>
|
157
|
+
<td>repository_name</td>
|
158
|
+
<td>
|
159
|
+
The name of the code repository holding this app. This is relative to the
|
160
|
+
project's repository.
|
161
|
+
</td>
|
162
|
+
<td><code>repository_name 'brownleej/mars'</code></td>
|
163
|
+
<td>None; this is required</td>
|
164
|
+
</tr>
|
165
|
+
<tr>
|
166
|
+
<td>database_name</td>
|
167
|
+
<td>
|
168
|
+
The name of the database this app uses. If this is not provided, the app
|
169
|
+
will not have any database configured automatically.
|
170
|
+
</td>
|
171
|
+
<td><code>database_name :apollo</code></td>
|
172
|
+
<td>nil</td>
|
173
|
+
</tr>
|
174
|
+
<tr>
|
175
|
+
<td>port</td>
|
176
|
+
<td>
|
177
|
+
<p>The port the app listens on.</p>
|
178
|
+
<p>
|
179
|
+
<strong>Note:</strong> The app servers will only be accessible within
|
180
|
+
the docker network; they will not be directly accessible from the host
|
181
|
+
machine or the outside world. For this reason, all of your apps can
|
182
|
+
share the same port without causing any conflicts.
|
183
|
+
</p>
|
184
|
+
</td>
|
185
|
+
<td><code>port 3000</code></td>
|
186
|
+
<td>8080</td>
|
187
|
+
</table>
|
188
|
+
|
189
|
+
# Adding Databases
|
190
|
+
|
191
|
+
Inside the project DSL, you can call `database :apollo, :mysql` to add a MySQL
|
192
|
+
database called `apollo`. You can also call `mysql_database :apollo` to do the
|
193
|
+
same thing. Both forms take a block, which allows you to call methods from
|
194
|
+
`RubyYacht::Database::DSL`.
|
195
|
+
|
196
|
+
You can call the `database` method multiple times to add multiple databases.
|
197
|
+
|
198
|
+
If you are using a different app type, you can supply that type instead of
|
199
|
+
`mysql`, but the app type must be defined through a [plugin](/gems/ruby_yacht/file/doc/plugins.md).
|
200
|
+
|
201
|
+
### Database Fields
|
202
|
+
|
203
|
+
<table>
|
204
|
+
<tr>
|
205
|
+
<th>Name</th>
|
206
|
+
<th>Description</th>
|
207
|
+
<th>Example</th>
|
208
|
+
<td>Default</td>
|
209
|
+
</tr>
|
210
|
+
<tr>
|
211
|
+
<td>host</td>
|
212
|
+
<td>
|
213
|
+
The name of the host that the database server is on. If you provide
|
214
|
+
`localhost`, this will create a database image and a database container
|
215
|
+
for the database. If you provide any other value, this will not create
|
216
|
+
any database image or container, and will only use the database config
|
217
|
+
to point the apps toward the correct external server.
|
218
|
+
</td>
|
219
|
+
<td><code>host 'db1.test.com'</code></td>
|
220
|
+
<td>None; this is required.</td>
|
221
|
+
</tr>
|
222
|
+
<tr>
|
223
|
+
<td>username</td>
|
224
|
+
<td>
|
225
|
+
The name of the user that the apps will use to connect to the database.
|
226
|
+
</td>
|
227
|
+
<td><code>username 'apollo'</code></td>
|
228
|
+
<td>None; this is required.</td>
|
229
|
+
</tr>
|
230
|
+
<tr>
|
231
|
+
<td>password</td>
|
232
|
+
<td>
|
233
|
+
The password that the apps will use to connect to the database.
|
234
|
+
</td>
|
235
|
+
<td><code>password 'testpass'</code></td>
|
236
|
+
<td>None; this is required.</td>
|
237
|
+
</tr>
|
238
|
+
<tr>
|
239
|
+
<td>container_label</td>
|
240
|
+
<td>
|
241
|
+
The label for the images and containers for this database. For instance,
|
242
|
+
if your project prefix is `apollo` and the container label for the
|
243
|
+
database is `mysql`, the image and container for the database will be
|
244
|
+
called `apollo-mysql`.
|
245
|
+
</td>
|
246
|
+
<td><code>container_label :mysql</code></td>
|
247
|
+
<td>database</td>
|
248
|
+
</tr>
|
249
|
+
</table>
|
250
|
+
|
251
|
+
# DNS Server Config
|
252
|
+
|
253
|
+
If your network has custom DNS servers, you can call `dns_server` inside of a
|
254
|
+
project block to define your DNS server config. The `dns_server` method takes
|
255
|
+
no arguents, but takes a block which allows you to call methods from
|
256
|
+
`RubyYacht::DnsServer::DSL`.
|
257
|
+
|
258
|
+
You should only call the `dns_server` once for a given project.
|
259
|
+
|
260
|
+
### DNS Server Fields
|
261
|
+
|
262
|
+
|
263
|
+
<table>
|
264
|
+
<tr>
|
265
|
+
<th>Name</th>
|
266
|
+
<th>Description</th>
|
267
|
+
<th>Example</th>
|
268
|
+
<td>Default</td>
|
269
|
+
</tr>
|
270
|
+
<tr>
|
271
|
+
<td>server</td>
|
272
|
+
<td>
|
273
|
+
The hostname or IP address for the DNS server. You can call this
|
274
|
+
multiple times to add multiple DNS servers
|
275
|
+
</td>
|
276
|
+
<td><code>server 'dns.test.com'</code></td>
|
277
|
+
<td>Empty; no DNS servers</td>
|
278
|
+
</tr>
|
279
|
+
<tr>
|
280
|
+
<td>search_domain</td>
|
281
|
+
<td>
|
282
|
+
The default search domains for server names. You can call this multiple
|
283
|
+
times to add multiple search domains.
|
284
|
+
</td>
|
285
|
+
<td><code>search_domain 'db.test.com'</code></td>
|
286
|
+
<td>Empty; no DNS search domains</td>
|
287
|
+
</tr>
|
288
|
+
</table>
|
289
|
+
|
290
|
+
# Default Plugins
|
291
|
+
|
292
|
+
By default, RubyYacht comes with two plugins, defined under the
|
293
|
+
`RubyYacht::Plugins` namespace:
|
294
|
+
|
295
|
+
* Rails, for defining app servers for Rails apps
|
296
|
+
* MySQL, for defining MySQL database servers
|
297
|
+
|
298
|
+
If you want to unload the default plugins, you can call
|
299
|
+
`RubyYacht.configuration.clear` before defining the rest of your configuration.
|
300
|
+
You can then load individual plugins by calling, for instance,
|
301
|
+
`RubyYacht::Plugins::MySQL.load`.
|
data/doc/configuration_sample.rb
CHANGED
@@ -27,14 +27,12 @@ RubyYacht.configure do
|
|
27
27
|
rails_secret_key_base 'abc'
|
28
28
|
|
29
29
|
# The configuration for the database the app uses.
|
30
|
-
database
|
30
|
+
# The apps will share a database called apollo
|
31
|
+
mysql_database :apollo do
|
31
32
|
# A database host of localhost tells ruby-yacht to build a database
|
32
33
|
# container for the apps' local database.
|
33
34
|
host "localhost"
|
34
35
|
|
35
|
-
# The apps will share a database called apollo
|
36
|
-
name "apollo"
|
37
|
-
|
38
36
|
# The credentials for accessing the database.
|
39
37
|
username "apollo"
|
40
38
|
password "test"
|
@@ -43,11 +41,13 @@ RubyYacht.configure do
|
|
43
41
|
rails_app :mars do
|
44
42
|
# This app's repository is at github.com/brownleej/mars
|
45
43
|
repository_name 'brownleej/mars'
|
44
|
+
database_name :apollo
|
46
45
|
end
|
47
46
|
|
48
47
|
rails_app :saturn do
|
49
48
|
# This app's repository is at github.com/brownleej/saturn
|
50
49
|
repository_name 'brownleej/saturn'
|
50
|
+
database_name :apollo
|
51
51
|
end
|
52
52
|
|
53
53
|
# This indicates that apollo.docker.local should serve requests to the mars
|
@@ -63,7 +63,7 @@ RubyYacht.configure do
|
|
63
63
|
repository "github.com"
|
64
64
|
rails_secret_key_base 'abc'
|
65
65
|
|
66
|
-
|
66
|
+
mysql_database :jupiter do
|
67
67
|
# Because this host has a real domain, we will not build a database
|
68
68
|
# container. The database at this host must be set up in advance with
|
69
69
|
# the database and the credentials in this file.
|
@@ -71,17 +71,19 @@ RubyYacht.configure do
|
|
71
71
|
# When the apps start, they will automatically run database migrations
|
72
72
|
# against this database.
|
73
73
|
host "db.test.com"
|
74
|
-
|
74
|
+
|
75
75
|
username "jupiter"
|
76
76
|
password "test"
|
77
77
|
end
|
78
78
|
|
79
79
|
rails_app :venus do
|
80
80
|
repository_name 'brownleej/venus'
|
81
|
+
database_name :jupiter
|
81
82
|
end
|
82
83
|
|
83
84
|
rails_app :saturn do
|
84
85
|
repository_name 'brownleej/saturn'
|
86
|
+
database_name :jupiter
|
85
87
|
end
|
86
88
|
|
87
89
|
# Because this project has no primary app, jupiter.docker.local will serve
|
@@ -9,4 +9,4 @@ requires caution when developing and running tests. The tests contain extensive
|
|
9
9
|
stubs to prevent them from interacting with a real docker environment, and you
|
10
10
|
should use the same techniques in your own tests. I would also recommend that
|
11
11
|
you run the tests within their own docker container. You can find tools for
|
12
|
-
building such a container in
|
12
|
+
building such a container in `spec/docker`.
|
data/doc/plugins.md
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
# Plugins
|
2
|
+
|
3
|
+
RubyYacht's plugin engine allows you to define your own server types, and add
|
4
|
+
custom hooks for what happens when building images and running containers.
|
5
|
+
|
6
|
+
You can define server types and hooks inside of a `RubyYacht.configure` block. Like
|
7
|
+
other parts of the configuration, they will not be committed until the
|
8
|
+
`configure` block is over. The app and database DSLs require that the server
|
9
|
+
types be committed, so you should add server types in a separate configuration
|
10
|
+
block from the one where you define your projects.
|
11
|
+
|
12
|
+
# Adding Server Types
|
13
|
+
|
14
|
+
You can call `server_type :mongo` to define a server type called `mongo`. The
|
15
|
+
`server_type` method takes a block, which allows you to call methods from
|
16
|
+
`RubyYacht::ServerType::DSL`.
|
17
|
+
|
18
|
+
### Server Type Fields
|
19
|
+
|
20
|
+
You can add the following fields to fill out the server type:
|
21
|
+
|
22
|
+
<table>
|
23
|
+
<tr>
|
24
|
+
<th>Name</th>
|
25
|
+
<th>Description</th>
|
26
|
+
<th>Example</th>
|
27
|
+
<th>Default</th>
|
28
|
+
</tr>
|
29
|
+
<tr>
|
30
|
+
<td>container_type</td>
|
31
|
+
<td>
|
32
|
+
The type of container that this server type applies to. This can be either
|
33
|
+
`app` or `database`.
|
34
|
+
</td>
|
35
|
+
<td>
|
36
|
+
<code>container_type :app</code>
|
37
|
+
</td>
|
38
|
+
<td>None; this is required.</td>
|
39
|
+
</tr>
|
40
|
+
<tr>
|
41
|
+
<td>baseline_image</td>
|
42
|
+
<td>
|
43
|
+
<p>
|
44
|
+
The docker image that we should use as the baseline for the images for
|
45
|
+
these servers.
|
46
|
+
</p>
|
47
|
+
<p>
|
48
|
+
This is currently only used for the app images.
|
49
|
+
</p>
|
50
|
+
</td>
|
51
|
+
<td>
|
52
|
+
<code>baseline_image 'ruby:2.3'</code>
|
53
|
+
</td>
|
54
|
+
<td>
|
55
|
+
None; this is required.
|
56
|
+
</td>
|
57
|
+
</tr>
|
58
|
+
<tr>
|
59
|
+
<td>project_attribute</td>
|
60
|
+
<td>
|
61
|
+
<p>This defines an attribute that can be set on a project.</p>
|
62
|
+
<p>
|
63
|
+
This can be set on any project once the server type has been loaded.
|
64
|
+
</p>
|
65
|
+
<p>
|
66
|
+
This accepts hash of options. The currently accepted options are `name`
|
67
|
+
and `default`. The full name of the attribute will be prefixed with the
|
68
|
+
name of the server type, to keep server types from defining conflicting
|
69
|
+
attributes.
|
70
|
+
</p>
|
71
|
+
</td>
|
72
|
+
<td><code>project_attribute name: :environment, default: 'staging'</code></td>
|
73
|
+
<td>None; no custom project attributes</td>
|
74
|
+
</tr>
|
75
|
+
<tr>
|
76
|
+
<td>server_attribute</td>
|
77
|
+
<td>
|
78
|
+
<p>This defines an attribute that can be set on a server.</p>
|
79
|
+
<p>
|
80
|
+
This can be set on any server of the matching type once the server type
|
81
|
+
has been loaded.
|
82
|
+
</p>
|
83
|
+
<p>
|
84
|
+
This accepts hash of options. The currently accepted options are `name`
|
85
|
+
and `default`. The full name of the attribute will be prefixed with the
|
86
|
+
name of the server type, to keep server types from defining conflicting
|
87
|
+
attributes.
|
88
|
+
</p>
|
89
|
+
</td>
|
90
|
+
<td><code>server_attribute name: :key</code></td>
|
91
|
+
<td>None; no custom server attributes</td>
|
92
|
+
</tr>
|
93
|
+
<tr>
|
94
|
+
<td>environment_variable</td>
|
95
|
+
<td>
|
96
|
+
<p>
|
97
|
+
A custom environment variable that is set in an image for this plugin.
|
98
|
+
</p>
|
99
|
+
<p>
|
100
|
+
This accepts two parameters (image and name), as well as a block. The
|
101
|
+
image is the type of image this is set on: app, app_dependencies, or
|
102
|
+
database. The block provides a value for the variable. The block will
|
103
|
+
have access to the context of the image we're building, as
|
104
|
+
<code>@project</code>, <code>@app</code>, and <code>@database</code>.
|
105
|
+
</p>
|
106
|
+
<p>
|
107
|
+
An app type plugin can also provide custom environment variable for a
|
108
|
+
database server.
|
109
|
+
</p>
|
110
|
+
<p>
|
111
|
+
You can call this multiple times to define multiple environment variables.
|
112
|
+
</p>
|
113
|
+
</td>
|
114
|
+
<td>
|
115
|
+
<code>
|
116
|
+
environment_variable :app_dependencies, 'RAILS_ENV' do
|
117
|
+
@project.rails_environment
|
118
|
+
end
|
119
|
+
</code>
|
120
|
+
</td>
|
121
|
+
<td>None; no custom environment variables.</td>
|
122
|
+
</tr>
|
123
|
+
</table>
|
124
|
+
|
125
|
+
# Adding Hooks
|
126
|
+
|
127
|
+
To define a hook, you can call `before`, `during`, or `after`, followed by an
|
128
|
+
event type. A before-hook is run before the event happens, an after-hook is run
|
129
|
+
after the event happens, and a during-hook provides the logic for making an
|
130
|
+
event happen.
|
131
|
+
|
132
|
+
These methods also take a block which allow you to call methods from
|
133
|
+
`RubyYacht::Hook::DSL`.
|
134
|
+
|
135
|
+
### Event Types
|
136
|
+
|
137
|
+
These are the event types that you can hook into:
|
138
|
+
|
139
|
+
<table>
|
140
|
+
<tr>
|
141
|
+
<th>Name</th>
|
142
|
+
<th>Description</th>
|
143
|
+
</tr>
|
144
|
+
<tr>
|
145
|
+
<td>startup</td>
|
146
|
+
<td>An app server is starting up.</td>
|
147
|
+
</tr>
|
148
|
+
<tr>
|
149
|
+
<td>build_checkout</td>
|
150
|
+
<td>
|
151
|
+
The code for an app is being checked out when building an app image.
|
152
|
+
</td>
|
153
|
+
</tr>
|
154
|
+
<tr>
|
155
|
+
<td>install_libraries</td>
|
156
|
+
<td>The libraries for an app or database server are being installed.</td>
|
157
|
+
</tr>
|
158
|
+
<tr>
|
159
|
+
<td>create_databases</td>
|
160
|
+
<td>The databases for a database server are being created.</td>
|
161
|
+
</tr>
|
162
|
+
<tr>
|
163
|
+
<td>load_database_seeds</td>
|
164
|
+
<td>The seed data for the app is being loaded on the database server.</td>
|
165
|
+
</tr>
|
166
|
+
</table>
|
167
|
+
|
168
|
+
### Fields
|
169
|
+
|
170
|
+
The hook DSL allows you to set the following fields:
|
171
|
+
|
172
|
+
<table>
|
173
|
+
<tr>
|
174
|
+
<th>Name</th>
|
175
|
+
<th>Description</th>
|
176
|
+
<th>Example</th>
|
177
|
+
<th>Default</th>
|
178
|
+
</tr>
|
179
|
+
<tr>
|
180
|
+
<td>server_type</td>
|
181
|
+
<td>The name of the server type that this hook applies to</td>
|
182
|
+
<td><code>server_type :rails</code></td>
|
183
|
+
<td>None; this is required</td>
|
184
|
+
</tr>
|
185
|
+
<tr>
|
186
|
+
<td>command</td>
|
187
|
+
<td>The shell command that should be run when the hook executes</td>
|
188
|
+
<td><code>command 'cp /var/docker/database.yml /var/code/config/'</code></td>
|
189
|
+
<td>
|
190
|
+
None; this is required. However, it can also be set by calling
|
191
|
+
`run_script`.
|
192
|
+
</td>
|
193
|
+
</tr>
|
194
|
+
<tr>
|
195
|
+
<td>script_folder</td>
|
196
|
+
<td>
|
197
|
+
The path to the folder in the host machine containing files to copy for
|
198
|
+
this hook.
|
199
|
+
</td>
|
200
|
+
<td><code>script_folder './scripts'</code></td>
|
201
|
+
<td>The working directory</td>
|
202
|
+
</tr>
|
203
|
+
<tr>
|
204
|
+
<td>copy_file</td>
|
205
|
+
<td>
|
206
|
+
The name of a file that should be copied from the host machine into the
|
207
|
+
image. This is relative to the hook's script folder.
|
208
|
+
</td>
|
209
|
+
<td><code>copy_file 'setup.rb'</code></td>
|
210
|
+
<td>None, meaning that no files are copied for this hook.</td>
|
211
|
+
</tr>
|
212
|
+
<tr>
|
213
|
+
<td>run_script</td>
|
214
|
+
<td>
|
215
|
+
This specifies that this hook runs a script from the host machine. This
|
216
|
+
will set the `copy_file` and the `command`.
|
217
|
+
</td>
|
218
|
+
<td><code>run_script 'setup.rb'</code></td>
|
219
|
+
<td>None; if you are not using this you must call `command` instead.</td>
|
220
|
+
</tr>
|
221
|
+
</table>
|
222
|
+
|
223
|
+
### Setting Defaults
|
224
|
+
|
225
|
+
Your plugins will likely have many hooks that are using some of the same
|
226
|
+
settings, so you can set defaults for them by calling `add_hooks`. This method
|
227
|
+
takes a hash containing options for the hooks, and a block for adding them. Any
|
228
|
+
hooks added in the block will have those options set.
|
229
|
+
|
230
|
+
The supported options are `script_folder` and `server_type`.
|
@@ -86,7 +86,7 @@ module RubyYacht
|
|
86
86
|
##
|
87
87
|
# :method: container_label
|
88
88
|
# You can call `container_label 'mysql'` to give this database a container
|
89
|
-
# name that is
|
89
|
+
# name that is (project)-mysql.
|
90
90
|
add_attribute :container_label, :database
|
91
91
|
|
92
92
|
creates_object Database
|
data/lib/ruby_yacht/dsl/hook.rb
CHANGED
data/ruby_yacht.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'ruby_yacht'
|
3
|
-
spec.version = '0.
|
4
|
-
spec.date = '2016-
|
3
|
+
spec.version = '0.5.0'
|
4
|
+
spec.date = '2016-05-05'
|
5
5
|
spec.description = "A DSL for building docker containers for a family of Rails apps"
|
6
6
|
spec.summary = "A DSL for building docker containers for a family of Rails apps"
|
7
7
|
spec.authors = ["John Brownlee"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_yacht
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Brownlee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -64,13 +64,16 @@ files:
|
|
64
64
|
- .rspec
|
65
65
|
- .rubocop.yml
|
66
66
|
- .travis.yml
|
67
|
+
- .yardopts
|
67
68
|
- Gemfile
|
68
69
|
- Gemfile.lock
|
69
70
|
- LICENSE
|
70
71
|
- README.md
|
71
|
-
- doc/CONTRIBUTING.md
|
72
72
|
- doc/TODO.md
|
73
|
+
- doc/configuration.md
|
73
74
|
- doc/configuration_sample.rb
|
75
|
+
- doc/contributing.md
|
76
|
+
- doc/plugins.md
|
74
77
|
- lib/ruby_yacht.rb
|
75
78
|
- lib/ruby_yacht/dsl.rb
|
76
79
|
- lib/ruby_yacht/dsl/app.rb
|