ruby_yacht 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/.rdoc_options +8 -2
  4. data/.rspec +1 -0
  5. data/.travis.yml +17 -1
  6. data/Gemfile.lock +18 -2
  7. data/README.md +28 -10
  8. data/bin/ruby_yacht +5 -0
  9. data/doc/TODO.md +1 -20
  10. data/doc/configuration.md +104 -21
  11. data/doc/configuration_sample.rb +19 -8
  12. data/doc/contributing.md +28 -5
  13. data/doc/plugins.md +105 -45
  14. data/lib/ruby_yacht/dsl/app.rb +14 -18
  15. data/lib/ruby_yacht/dsl/configuration.rb +51 -32
  16. data/lib/ruby_yacht/dsl/database.rb +24 -8
  17. data/lib/ruby_yacht/dsl/dsl.rb +32 -4
  18. data/lib/ruby_yacht/dsl/hook.rb +182 -48
  19. data/lib/ruby_yacht/dsl/project.rb +20 -14
  20. data/lib/ruby_yacht/dsl/server_type.rb +14 -31
  21. data/lib/ruby_yacht/dsl/web_server.rb +87 -0
  22. data/lib/ruby_yacht/dsl.rb +1 -0
  23. data/lib/ruby_yacht/images/app/Dockerfile.erb +17 -6
  24. data/lib/ruby_yacht/images/app/before_startup.bash.erb +5 -3
  25. data/lib/ruby_yacht/images/app/startup.bash.erb +5 -2
  26. data/lib/ruby_yacht/images/app-dependencies/Dockerfile.erb +7 -11
  27. data/lib/ruby_yacht/images/database/Dockerfile.erb +7 -18
  28. data/lib/ruby_yacht/images/database/startup.bash.erb +1 -1
  29. data/lib/ruby_yacht/images/web/Dockerfile.erb +25 -19
  30. data/lib/ruby_yacht/plugins/mysql.rb +18 -8
  31. data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/add_app.rb +5 -5
  32. data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/add_project.rb +3 -3
  33. data/lib/ruby_yacht/plugins/nginx.rb +28 -0
  34. data/lib/ruby_yacht/plugins/rails/scripts/build_new_app.rb +10 -0
  35. data/lib/ruby_yacht/plugins/rails/scripts/update_rails_config.rb +6 -1
  36. data/lib/ruby_yacht/plugins/rails.rb +34 -19
  37. data/lib/ruby_yacht/plugins.rb +2 -1
  38. data/lib/ruby_yacht/runner/build_images.rb +87 -73
  39. data/lib/ruby_yacht/runner/checkout.rb +1 -1
  40. data/lib/ruby_yacht/runner/command.rb +13 -1
  41. data/lib/ruby_yacht/runner/create_new_project.rb +91 -0
  42. data/lib/ruby_yacht/runner/help.rb +1 -1
  43. data/lib/ruby_yacht/runner/run_containers.rb +17 -21
  44. data/lib/ruby_yacht/runner/runner.rb +27 -2
  45. data/lib/ruby_yacht/runner/services.rb +15 -10
  46. data/lib/ruby_yacht/runner/shell.rb +1 -1
  47. data/lib/ruby_yacht/runner/update_hosts.rb +16 -11
  48. data/lib/ruby_yacht/runner.rb +1 -0
  49. data/log/.gitkeep +0 -0
  50. data/ruby_yacht.gemspec +4 -2
  51. data/spec/docker/Dockerfile +19 -3
  52. data/spec/docker/install_gems.bash +5 -0
  53. data/spec/docker/run.bash +44 -0
  54. data/spec/docker/startup.bash +10 -0
  55. data/spec/dsl/app_spec.rb +66 -38
  56. data/spec/dsl/configuration_spec.rb +236 -30
  57. data/spec/dsl/database_spec.rb +103 -4
  58. data/spec/dsl/dsl_spec.rb +46 -3
  59. data/spec/dsl/hook_spec.rb +278 -57
  60. data/spec/dsl/project_spec.rb +75 -45
  61. data/spec/dsl/server_type_spec.rb +52 -12
  62. data/spec/dsl/web_server_spec.rb +160 -0
  63. data/spec/fixtures/apollo-new-project-config +20 -0
  64. data/spec/fixtures/app-dependencies-dockerfile-generic +4 -7
  65. data/spec/fixtures/app-dependencies-dockerfile-generic-with-library-install +6 -10
  66. data/spec/fixtures/app-dependencies-dockerfile-rails +9 -11
  67. data/spec/fixtures/app-dependencies-dockerfile-with-no-repository +20 -0
  68. data/spec/fixtures/database-dockerfile +1 -1
  69. data/spec/fixtures/database-dockerfile-mysql +3 -3
  70. data/spec/fixtures/database-dockerfile-rails +5 -4
  71. data/spec/fixtures/database-dockerfile-rails-with-no-repository +27 -0
  72. data/spec/fixtures/database-dockerfile-with-seed-hooks +3 -3
  73. data/spec/fixtures/database-startup-mysql +2 -1
  74. data/spec/fixtures/mars-before-startup +2 -2
  75. data/spec/fixtures/mars-before-startup-rails +5 -4
  76. data/spec/fixtures/mars-before-startup-with-before-startup-hooks +5 -4
  77. data/spec/fixtures/mars-before-startup-with-custom-file-copy +3 -3
  78. data/spec/fixtures/mars-before-startup-with-no-repository +3 -0
  79. data/spec/fixtures/mars-dockerfile +3 -2
  80. data/spec/fixtures/mars-dockerfile-rails +6 -5
  81. data/spec/fixtures/mars-dockerfile-rails-with-no-repository +32 -0
  82. data/spec/fixtures/mars-dockerfile-with-after-checkout-hooks +5 -4
  83. data/spec/fixtures/mars-dockerfile-with-before-startup-hooks +5 -4
  84. data/spec/fixtures/mars-dockerfile-with-custom-file-copy +4 -3
  85. data/spec/fixtures/mars-dockerfile-with-local-database +4 -2
  86. data/spec/fixtures/mars-dockerfile-with-no-repository +22 -0
  87. data/spec/fixtures/mars-dockerfile-with-remote-database +4 -2
  88. data/spec/fixtures/mars-startup +2 -2
  89. data/spec/fixtures/mars-startup-rails +2 -2
  90. data/spec/fixtures/mars-startup-rails-with-no-repository +5 -0
  91. data/spec/fixtures/mars-startup-with-no-repository +4 -0
  92. data/spec/fixtures/web-dockerfile +18 -11
  93. data/spec/fixtures/web-dockerfile-jupiter +28 -0
  94. data/spec/fixtures/web-dockerfile-nginx +38 -0
  95. data/spec/fixtures/web-dockerfile-with-eponymous-app +16 -10
  96. data/spec/fixtures/web-dockerfile-with-primary-app +16 -10
  97. data/spec/integration/build_images_spec.rb +210 -0
  98. data/spec/integration/build_spec.rb +23 -0
  99. data/spec/integration/checkout_spec.rb +94 -0
  100. data/spec/integration/create_new_project_spec.rb +50 -0
  101. data/spec/integration/implode_spec.rb +20 -0
  102. data/spec/integration/run.rb +93 -0
  103. data/spec/integration/run_containers_spec.rb +279 -0
  104. data/spec/integration/services_spec.rb +99 -0
  105. data/spec/integration/shell_spec.rb +31 -0
  106. data/spec/integration/update_hosts_spec.rb +35 -0
  107. data/spec/plugins/mysql_spec.rb +18 -1
  108. data/spec/plugins/nginx_spec.rb +66 -0
  109. data/spec/plugins/rails_spec.rb +61 -89
  110. data/spec/runner/build_images_spec.rb +111 -58
  111. data/spec/runner/command_spec.rb +55 -3
  112. data/spec/runner/create_new_project_spec.rb +93 -0
  113. data/spec/runner/help_spec.rb +5 -1
  114. data/spec/runner/run_containers_spec.rb +22 -10
  115. data/spec/runner/runner_spec.rb +31 -4
  116. data/spec/runner/services_spec.rb +32 -4
  117. data/spec/runner/update_hosts_spec.rb +2 -1
  118. data/spec/spec_helper.rb +16 -1
  119. data/spec/support/integration_helpers.rb +76 -0
  120. data/spec/support/test_project.rb +15 -3
  121. metadata +97 -14
  122. data/spec/docker/build.bash +0 -10
  123. data/spec/fixtures/deploy-dockerfile +0 -2
  124. data/spec/fixtures/multi-project-web-dockerfile +0 -25
  125. /data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/app_config.erb +0 -0
  126. /data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/index.html.erb +0 -0
  127. /data/lib/ruby_yacht/{images/web → plugins/nginx/scripts}/index_config.erb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 724d4833d4fccb763b4173463fd4d39a6c72b5af
4
- data.tar.gz: 385d64ac428190fe57096eeb5382f03fd3de4099
3
+ metadata.gz: a361c6c7a0ed8037cf5030012a0817839bf6b2ff
4
+ data.tar.gz: e2fecb59ced73e241e268cd601dcfdd80e16aa2b
5
5
  SHA512:
6
- metadata.gz: 3acb66557ac774872c8548f5afc9bb3e9a0e5fa5b189e5c2846e19eed7e3afbe1f7ee3b7345140ace4ae838d5b2315f538a53745219896f7ee94a06b1c9f35d1
7
- data.tar.gz: fad7d2289310ee0c3ffed0f02250d1c86060bdf0f64ea3c1190c343eaa05a965595e2b15aa3fdd54807f458303244807235d1aceae57031f449cc7578ff519f9
6
+ metadata.gz: ecd0d6522211c695a253bb86a45de1fc8a8a9f4f13cce0e19b4f9c7b9e3b96506d2792b4d12972571813a19360f4a7b0f304cb2e2d285d3abd60171cb2a9eb21
7
+ data.tar.gz: 4880e951c8696e057546ca1801c2e44f26850db49af1a8c611c8d04c08ed9e8b8f102d1c25219aea7b129530731ca8f13676f1384847022d965d5b9bcae34c16
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
1
  tmp
2
+ log/*.txt
2
3
  *.gem
3
4
  doc/coverage
4
5
  doc/code
5
6
  doc/yard
6
- .yardoc
7
+ .yardoc
8
+ .byebug_history
data/.rdoc_options CHANGED
@@ -4,14 +4,20 @@ static_path: []
4
4
  rdoc_include:
5
5
  - "."
6
6
  charset: UTF-8
7
- exclude:
8
- - "spec"
7
+ exclude:
9
8
  - ".gem"
10
9
  - ".gemspec"
11
10
  - "nohup.out"
12
11
  - "Gemfile"
13
12
  - "doc/coverage"
14
13
  - "doc/yard"
14
+ - "doc/code"
15
+ - "lib/ruby_yacht/images"
16
+ - "lib/ruby_yacht/plugins/mysql/scripts"
17
+ - "lib/ruby_yacht/plugins/rails/scripts"
18
+ - "log"
19
+ - "spec"
20
+ - "tmp"
15
21
  hyperlink_all: false
16
22
  line_numbers: false
17
23
  locale:
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ -t ~integration
data/.travis.yml CHANGED
@@ -1,4 +1,20 @@
1
+ sudo: required
2
+ services:
3
+ - docker
4
+
1
5
  language: ruby
2
6
  rvm:
3
7
  - 2.2
4
- script: bundle exec rspec spec
8
+
9
+ before_install:
10
+ - sudo apt-get -o Dpkg::Options::="--force-confnew" install -y docker-engine
11
+ - docker version
12
+ - echo -e $SSH_ID_RSA > ~/.ssh/id_rsa
13
+ - chmod 600 ~/.ssh/id_rsa
14
+ script:
15
+ - bash spec/docker/run.bash -O /dev/null
16
+
17
+ notifications:
18
+ email:
19
+ recipients:
20
+ - mail@johnbrownlee.com
data/Gemfile.lock CHANGED
@@ -1,16 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_yacht (0.4.3)
4
+ ruby_yacht (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ ast (2.2.0)
10
+ byebug (9.0.0)
9
11
  codeclimate-test-reporter (0.5.0)
10
12
  simplecov (>= 0.7.1, < 1.0.0)
11
13
  diff-lcs (1.2.5)
12
14
  docile (1.1.5)
13
15
  json (1.8.3)
16
+ parser (2.3.1.0)
17
+ ast (~> 2.2)
18
+ powerpack (0.1.1)
19
+ rainbow (2.1.0)
14
20
  rspec (3.4.0)
15
21
  rspec-core (~> 3.4.0)
16
22
  rspec-expectations (~> 3.4.0)
@@ -24,21 +30,31 @@ GEM
24
30
  diff-lcs (>= 1.2.0, < 2.0)
25
31
  rspec-support (~> 3.4.0)
26
32
  rspec-support (3.4.1)
33
+ rubocop (0.40.0)
34
+ parser (>= 2.3.1.0, < 3.0)
35
+ powerpack (~> 0.1)
36
+ rainbow (>= 1.99.1, < 3.0)
37
+ ruby-progressbar (~> 1.7)
38
+ unicode-display_width (~> 1.0, >= 1.0.1)
39
+ ruby-progressbar (1.8.0)
27
40
  simplecov (0.11.2)
28
41
  docile (~> 1.1.0)
29
42
  json (~> 1.8)
30
43
  simplecov-html (~> 0.10.0)
31
44
  simplecov-html (0.10.0)
32
45
  timecop (0.8.1)
46
+ unicode-display_width (1.0.5)
33
47
 
34
48
  PLATFORMS
35
49
  ruby
36
50
 
37
51
  DEPENDENCIES
52
+ byebug
38
53
  codeclimate-test-reporter
39
54
  rspec
55
+ rubocop
40
56
  ruby_yacht!
41
57
  timecop
42
58
 
43
59
  BUNDLED WITH
44
- 1.11.2
60
+ 1.12.2
data/README.md CHANGED
@@ -27,11 +27,19 @@ 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 [the configuration documentation](/gems/ruby_yacht/file/doc/configuration.md)
30
+ read [the configuration documentation](http://www.rubydoc.info/gems/ruby_yacht/file/doc/configuration.md)
31
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
 
35
+ You can also use the `ruby_yacht` command to generate a new project:
36
+
37
+ ruby_yacht new test test-config
38
+
39
+ This will generate a `run.rb` file in `test-config/run.rb`, with sample config
40
+ for a project called `test`. You can then fill it in with the details of your
41
+ applications, as explained in the configuration documentation.
42
+
35
43
  # RubyYacht Scripts
36
44
 
37
45
  RubyYacht provides several scripts to build and manage your application
@@ -70,7 +78,7 @@ it will build the following images:
70
78
 
71
79
  <table>
72
80
  <tr>
73
- <td>apollo-app-dependencies</td>
81
+ <td>apollo-rails-app-dependencies</td>
74
82
  <td>
75
83
  An image with mars and saturn checked out, and all of their dependencies
76
84
  installed
@@ -98,7 +106,15 @@ it will build the following images:
98
106
  </td>
99
107
  </tr>
100
108
  <tr>
101
- <td>jupiter-app-dependencies</td>
109
+ <td>apollo-web</td>
110
+ <td>
111
+ An image with nginx installed, and set up to proxy the app containers for
112
+ apollo-mars and apollo-saturn. Each app will get a subdomain of the
113
+ project's main domain, with the subdomain named after the app.
114
+ </td>
115
+ </tr>
116
+ <tr>
117
+ <td>jupiter-rails-app-dependencies</td>
102
118
  <td>
103
119
  An image with venus and saturn checked out, and all of their dependencies
104
120
  installed
@@ -119,12 +135,10 @@ it will build the following images:
119
135
  </td>
120
136
  </tr>
121
137
  <tr>
122
- <td>apollo-web</td>
138
+ <td>jupiter-web</td>
123
139
  <td>
124
140
  An image with nginx installed, and set up to proxy the app containers for
125
- apollo-mars, apollo-saturn, jupiter-venus, and jupiter-saturn. Each app
126
- will get a subdomain of the project's main domain, with the subdomain named
127
- after the app.
141
+ jupiter-venus and jupiter-saturn.
128
142
  </td>
129
143
  </tr>
130
144
  </table>
@@ -198,9 +212,13 @@ any additional commands you pass it will be forwarded to the container and run.
198
212
 
199
213
  For instance, you can run `ruby run.rb shell mars` to open a bash shell in the
200
214
  mars app container, or `ruby run.rb shell mars rails c` to open a
201
- rails console, or `ruby run.rb shell mars tail -f log/development.log` to start
215
+ rails console, or `ruby run.rb shell mars "tail -f log/development.log"` to start
202
216
  reading all the content printed to the development log file.
203
217
 
218
+ If the command you want to run has any flags in it, like the `-f` above, you
219
+ must enclose the command in quotes to prevent RubyYacht from trying to consume
220
+ that as a flag of its own.
221
+
204
222
  ### checkout
205
223
 
206
224
  This checks out a new branch inside an app container, and restarts the app
@@ -212,7 +230,7 @@ the latest changes from the repository.
212
230
 
213
231
  # Plugins and Customization
214
232
 
215
- RubyYacht has a [plugin API](/gems/ruby_yacht/file/doc/plugins.md) for
233
+ RubyYacht has a [plugin API](http://www.rubydoc.info/gems/ruby_yacht/file/doc/plugins.md) for
216
234
  customizing the behavior of your scripts. You can use plugins for defining new
217
235
  app types or database types, or for adding hooks for the built-in types. This
218
236
  plugin API is so powerful that all of the rails-specific and mysql-specific code
@@ -221,5 +239,5 @@ in RubyYacht is provided through plugins.
221
239
  # Additional Information
222
240
 
223
241
  If you're interested in contributing to the project, you can find more
224
- information in [the contributing documentation](/gems/ruby_yacht/file/doc/contributing.md).
242
+ information in [the contributing documentation](http://www.rubydoc.info/gems/ruby_yacht/file/doc/contributing.md).
225
243
  You can also reach out to me on Twitter [@brownleej](https://twitter.com/brownleej)
data/bin/ruby_yacht ADDED
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/ruby
2
+
3
+ require 'ruby_yacht'
4
+ RubyYacht::Runner.load_default_commands(false)
5
+ RubyYacht::Runner.run
data/doc/TODO.md CHANGED
@@ -3,23 +3,4 @@ for open tickets.
3
3
 
4
4
  # General
5
5
 
6
- * Do more testing with remote databases and non-development environments
7
- * Consider whether using the same web server for multiple projects is the best
8
- approach
9
- * Look into issues with running shell command that has its own command-line
10
- flags.
11
- * Create shorthands for loading config from external files.
12
-
13
- # Plugins
14
-
15
- * Better support for rails apps with no database
16
- * Configurable ports for database servers
17
- * Support for SQLite databases
18
-
19
- # More customization
20
-
21
- * Defining custom commands
22
- * Allowing customization points at different levels, like adding hooks to
23
- individual apps
24
- * Customizing how we check out the repositories, so that people can use https
25
- instead of SSH.
6
+ * Test on Windows
data/doc/configuration.md CHANGED
@@ -39,15 +39,6 @@ You can provide the following fields.
39
39
  <td><code>system_prefix :foo</code></td>
40
40
  <td>None; this is required.</td>
41
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
42
  <tr>
52
43
  <td>repository</td>
53
44
  <td>
@@ -87,8 +78,8 @@ You can provide the following fields.
87
78
  </tr>
88
79
  </table>
89
80
 
90
- Inside a project block, you also define databases, DNS servers, and apps, as
91
- described below.
81
+ Inside a project block, you also define databases, DNS servers, web servers,
82
+ and apps, as described below.
92
83
 
93
84
  ### Plugin-Specific Fields
94
85
 
@@ -126,6 +117,15 @@ will also have the following fields:
126
117
  <td><code>rails_secret_key_base 'abc123'</code></td>
127
118
  <td>None; this is required</td>
128
119
  </tr>
120
+ <tr>
121
+ <td>rails_excluded_gem_groups</td>
122
+ <td>
123
+ The gem groups from the Gemfile that should not be installed on the
124
+ server.
125
+ </td>
126
+ <td><code>rails_excluded_gem_groups %w(development test)</code></td>
127
+ <td>An empty array</td>
128
+ </tr>
129
129
  </table>
130
130
 
131
131
  For more information about working with the default plugins, see
@@ -133,12 +133,13 @@ For more information about working with the default plugins, see
133
133
 
134
134
  # Adding Apps
135
135
 
136
- Inside the project DSL, you can call `app :mars, :rails` to add a Rails app
136
+ Inside the project DSL, you can call `app :rails, :mars` to add a Rails app
137
137
  called `mars`. You can also call `rails_app :mars` to do the same thing. Both
138
138
  forms take a block, which allows you to call methods from `RubyYacht::App::DSL`.
139
139
 
140
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).
141
+ `rails`, but the app type must be defined through a
142
+ [plugin](http://www.rubydoc.info/gems/ruby_yacht/file/doc/plugins.md).
142
143
 
143
144
  You can call the `app` method multiple times to add multiple databases.
144
145
 
@@ -156,11 +157,20 @@ You can provide the following fields in the app DSL:
156
157
  <tr>
157
158
  <td>repository_name</td>
158
159
  <td>
159
- The name of the code repository holding this app. This is relative to the
160
- project's repository.
160
+ <p>
161
+ The name of the code repository holding this app. This is relative to
162
+ the project's repository.
163
+ </p>
164
+ <p>
165
+ If this is nil, then the scripts will create a new app instead of trying
166
+ to check out an existing one. When combined with the `check_out_locally`
167
+ flag on the project, this can be a good way to bootstrap new apps.
168
+ </p>
161
169
  </td>
162
170
  <td><code>repository_name 'brownleej/mars'</code></td>
163
- <td>None; this is required</td>
171
+ <td>
172
+ nil
173
+ </td>
164
174
  </tr>
165
175
  <tr>
166
176
  <td>database_name</td>
@@ -188,15 +198,16 @@ You can provide the following fields in the app DSL:
188
198
 
189
199
  # Adding Databases
190
200
 
191
- Inside the project DSL, you can call `database :apollo, :mysql` to add a MySQL
201
+ Inside the project DSL, you can call `database :mysql, :apollo` to add a MySQL
192
202
  database called `apollo`. You can also call `mysql_database :apollo` to do the
193
203
  same thing. Both forms take a block, which allows you to call methods from
194
204
  `RubyYacht::Database::DSL`.
195
205
 
196
206
  You can call the `database` method multiple times to add multiple databases.
197
207
 
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).
208
+ If you are using a different database type, you can supply that type instead of
209
+ `mysql`, but the database type must be defined through a
210
+ [plugin](http://www.rubydoc.info/gems/ruby_yacht/file/doc/plugins.md).
200
211
 
201
212
  ### Database Fields
202
213
 
@@ -235,6 +246,17 @@ If you are using a different app type, you can supply that type instead of
235
246
  <td><code>password 'testpass'</code></td>
236
247
  <td>None; this is required.</td>
237
248
  </tr>
249
+ <tr>
250
+ <td>port</td>
251
+ <td>
252
+ The port that the database server listens on.
253
+ </td>
254
+ <td><code>port 3377</code></td>
255
+ <td>
256
+ In general, this does not have a default value. For MySQL databases,
257
+ though, this will be set to 3306 by default.
258
+ </td>
259
+ </tr>
238
260
  <tr>
239
261
  <td>container_label</td>
240
262
  <td>
@@ -248,6 +270,59 @@ If you are using a different app type, you can supply that type instead of
248
270
  </tr>
249
271
  </table>
250
272
 
273
+ # Adding Web Servers
274
+
275
+ The app containers will not publish their ports to the host machine or the
276
+ outside world, so you need to define web servers that serve as a proxy for them.
277
+ Inside the project DSL, you can call `web_server :nginx` to add an Nginx
278
+ web server. You can also call `nginx_web_server` to do the
279
+ same thing. Both forms take a block, which allows you to call methods from
280
+ `RubyYacht::WebServer::DSL`.
281
+
282
+ By default, the web server will be called `web`, and its image name and
283
+ container name will have the format `apollo-web`, where `apollo` is the system
284
+ prefix for the project. If you want to use a different name, you can pass this
285
+ as an argument to `web_server` or `nginx_web_server`.
286
+
287
+ You can call the `web_server` method multiple times to add multiple servers.
288
+ The scripts will try to start all of the web servers for your projects at once,
289
+ which will cause conflicts if they are trying to listen on the same port. This
290
+ is also a potential problem if you have multiple projects in the same
291
+ configuration file, since each project will need its own web server.
292
+
293
+ If you are using a different web server type, you can supply that type instead
294
+ of `nginx`, but the server type must be defined through a
295
+ [plugin](http://www.rubydoc.info/gems/ruby_yacht/file/doc/plugins.md).
296
+
297
+ <table>
298
+ <tr>
299
+ <th>Name</th>
300
+ <th>Description</th>
301
+ <th>Example</th>
302
+ <td>Default</td>
303
+ </tr>
304
+ <tr>
305
+ <td>domain</td>
306
+ <td>
307
+ The main domain for this server. Different apps will be added as
308
+ subdomains of this main domain.
309
+ </td>
310
+ <td><code>domain 'test.com'</code></td>
311
+ <td>None; this is required.</td>
312
+ </tr>
313
+ <tr>
314
+ <td>port</td>
315
+ <td>
316
+ The port that this server listens on. This is the port on the
317
+ *host machine* that the requests will come into. Inside the container, the
318
+ server will always listen on port 80, and it will be mapped to this port=
319
+ on the host.
320
+ </td>
321
+ <td><code>port 8080</code></td>
322
+ <td>80</td>
323
+ </tr>
324
+ </table>
325
+
251
326
  # DNS Server Config
252
327
 
253
328
  If your network has custom DNS servers, you can call `dns_server` inside of a
@@ -289,13 +364,21 @@ You should only call the `dns_server` once for a given project.
289
364
 
290
365
  # Default Plugins
291
366
 
292
- By default, RubyYacht comes with two plugins, defined under the
367
+ By default, RubyYacht comes with three plugins, defined under the
293
368
  `RubyYacht::Plugins` namespace:
294
369
 
295
370
  * Rails, for defining app servers for Rails apps
296
371
  * MySQL, for defining MySQL database servers
372
+ * Nginx, for defining Nginx web servers.
297
373
 
298
374
  If you want to unload the default plugins, you can call
299
375
  `RubyYacht.configuration.clear` before defining the rest of your configuration.
300
376
  You can then load individual plugins by calling, for instance,
301
- `RubyYacht::Plugins::MySQL.load`.
377
+ `RubyYacht::Plugins::MySQL.load`.
378
+
379
+ # Miscellaneous Configuration
380
+
381
+ The `disable_docker_machine` flag on `RubyYacht.configuration` forces the scripts
382
+ to act as though docker-machine is not installed. This can be helpful if you are
383
+ running a Docker for Mac or Docker for Windows beta alongside a docker-machine-based
384
+ installation.
@@ -6,13 +6,6 @@ RubyYacht.configure do
6
6
  # 'apollo-'
7
7
  system_prefix :apollo
8
8
 
9
- # The web server will place the apps under 'apollo.docker.local'
10
- #
11
- # apollo.docker.local will point to a landing page with links to the apps,
12
- # and individual apps will be available at mars.apollo.docker.local and
13
- # saturn.apollo.docker.local
14
- domain "apollo.docker.local"
15
-
16
9
  # The repositories for the apps in this project will all be available at the
17
10
  # domain github.com.
18
11
  #
@@ -53,13 +46,21 @@ RubyYacht.configure do
53
46
  # This indicates that apollo.docker.local should serve requests to the mars
54
47
  # app.
55
48
  primary_app :mars
49
+
50
+ nginx_web_server do
51
+ # The web server will place the apps under 'apollo.docker.local'
52
+ #
53
+ # apollo.docker.local will point to a landing page with links to the apps,
54
+ # and individual apps will be available at mars.apollo.docker.local and
55
+ # saturn.apollo.docker.local
56
+ domain "apollo.docker.local"
57
+ end
56
58
  end
57
59
 
58
60
  # This is a second project that runs a different set of apps, with different
59
61
  # domains and a separate database.
60
62
  project :jupiter do
61
63
  system_prefix :jupiter
62
- domain "jupiter.docker.local"
63
64
  repository "github.com"
64
65
  rails_secret_key_base 'abc'
65
66
 
@@ -88,6 +89,16 @@ RubyYacht.configure do
88
89
 
89
90
  # Because this project has no primary app, jupiter.docker.local will serve
90
91
  # an ad-hoc landing page with links to the individual apps.
92
+
93
+
94
+
95
+ nginx_web_server do
96
+ domain "jupiter.docker.local"
97
+
98
+ # This project's web server will listen on port 8080, instead of the
99
+ # default port 80.
100
+ port 8080
101
+ end
91
102
  end
92
103
  end
93
104
 
data/doc/contributing.md CHANGED
@@ -4,9 +4,32 @@ release, and that will likely shape decisions about what gets accepted into the
4
4
  core and what should remain in individual's projects. You can start by opening
5
5
  a pull request with a fix, or an issue with a suggestion for a new feature.
6
6
 
7
+ ### Tests
8
+
7
9
  All pull requests must contain test coverage. The nature of this project
8
- requires caution when developing and running tests. The tests contain extensive
9
- stubs to prevent them from interacting with a real docker environment, and you
10
- should use the same techniques in your own tests. I would also recommend that
11
- you run the tests within their own docker container. You can find tools for
12
- building such a container in `spec/docker`.
10
+ requires caution when developing and running tests. The unit tests contain
11
+ extensive stubs to prevent them from interacting with a real docker environment,
12
+ and you should use the same techniques in your own unit tests. The integration
13
+ tests, on the other hand, directly interact with docker so that we can test the
14
+ behavior of real containers. The images and containers for our tests will all be
15
+ prefixed with `apollo`, so you must not have any images or containers in your
16
+ environment that start with that prefix. They will be overwritten and removed in
17
+ the course of running the integration tests. The integration tests also update
18
+ the contents of the hosts file on the system. Though the tests are designed not
19
+ to persist any modifications, it is *strongly* recommended that you run the
20
+ tests inside a docker container.
21
+
22
+ If you want to run your tests in a docker container, you can run
23
+ `bash spec/docker/run.bash`, followed by the flags you want to pass to RSpec.
24
+ By default, it will skip integration tests, but you can tell it to only run the
25
+ integration tests by passing `-t integration` to rspec. This will build an image
26
+ called `ruby-yacht-tests` and run rspec in a container based off of that image.
27
+ That container will have its own docker environment, and it will start with a
28
+ fresh set of containers every time you run it. This causes the tests to be very
29
+ slow, which can be frustrating if you are running a few tests repeatedly as you
30
+ make changes to the code. To speed this up, you can run the script with the
31
+ PRESERVE_IMAGES flag, `PRESERVE_IMAGES=1 bash spec/docker/run.bash`. This will
32
+ change the ruby-yacht-tests container to be daemonized and stay open
33
+ indefinitely, and then run rspec in a separate process on the container. Once
34
+ the specs are done, they will leave the built images on that container, and the
35
+ specs will run faster the next time you run them.