ruby_yacht 0.1.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 (82) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +27 -0
  3. data/.gitignore +4 -0
  4. data/.rdoc_options +29 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +1156 -0
  7. data/.travis.yml +4 -0
  8. data/Gemfile +3 -0
  9. data/Gemfile.lock +44 -0
  10. data/LICENSE +8 -0
  11. data/README.md +216 -0
  12. data/doc/CONTRIBUTING.md +12 -0
  13. data/doc/TODO.md +28 -0
  14. data/doc/configuration_sample.rb +87 -0
  15. data/lib/ruby_yacht/dsl/app.rb +59 -0
  16. data/lib/ruby_yacht/dsl/configuration.rb +55 -0
  17. data/lib/ruby_yacht/dsl/database.rb +57 -0
  18. data/lib/ruby_yacht/dsl/dns_server.rb +38 -0
  19. data/lib/ruby_yacht/dsl/dsl.rb +252 -0
  20. data/lib/ruby_yacht/dsl/project.rb +140 -0
  21. data/lib/ruby_yacht/dsl.rb +6 -0
  22. data/lib/ruby_yacht/images/app/Dockerfile.erb +32 -0
  23. data/lib/ruby_yacht/images/app/checkout.rb +7 -0
  24. data/lib/ruby_yacht/images/app/startup.rb +17 -0
  25. data/lib/ruby_yacht/images/app/update_database_config.rb +45 -0
  26. data/lib/ruby_yacht/images/app-dependencies/Dockerfile.erb +23 -0
  27. data/lib/ruby_yacht/images/app-dependencies/install_gems.rb +12 -0
  28. data/lib/ruby_yacht/images/database/Dockerfile.erb +26 -0
  29. data/lib/ruby_yacht/images/database/load_seeds.rb +42 -0
  30. data/lib/ruby_yacht/images/database/setup.rb +19 -0
  31. data/lib/ruby_yacht/images/database/setup_database.sql.erb +12 -0
  32. data/lib/ruby_yacht/images/deploy/Dockerfile.erb +2 -0
  33. data/lib/ruby_yacht/images/web/Dockerfile.erb +25 -0
  34. data/lib/ruby_yacht/images/web/add_app.rb +12 -0
  35. data/lib/ruby_yacht/images/web/add_project.rb +14 -0
  36. data/lib/ruby_yacht/images/web/app_config.erb +11 -0
  37. data/lib/ruby_yacht/images/web/index.html.erb +10 -0
  38. data/lib/ruby_yacht/images/web/index_config.erb +12 -0
  39. data/lib/ruby_yacht/images/web/setup.rb +22 -0
  40. data/lib/ruby_yacht/runner/build.rb +21 -0
  41. data/lib/ruby_yacht/runner/build_images.rb +82 -0
  42. data/lib/ruby_yacht/runner/checkout.rb +68 -0
  43. data/lib/ruby_yacht/runner/command.rb +161 -0
  44. data/lib/ruby_yacht/runner/help.rb +55 -0
  45. data/lib/ruby_yacht/runner/implode.rb +33 -0
  46. data/lib/ruby_yacht/runner/run_containers.rb +105 -0
  47. data/lib/ruby_yacht/runner/runner.rb +42 -0
  48. data/lib/ruby_yacht/runner/services.rb +79 -0
  49. data/lib/ruby_yacht/runner/shell.rb +66 -0
  50. data/lib/ruby_yacht/runner/update_hosts.rb +72 -0
  51. data/lib/ruby_yacht/runner.rb +18 -0
  52. data/lib/ruby_yacht.rb +6 -0
  53. data/ruby_yacht.gemspec +18 -0
  54. data/spec/docker/Dockerfile +5 -0
  55. data/spec/docker/build.bash +10 -0
  56. data/spec/dsl/app_spec.rb +47 -0
  57. data/spec/dsl/configuration_spec.rb +64 -0
  58. data/spec/dsl/database_spec.rb +75 -0
  59. data/spec/dsl/dns_server_spec.rb +25 -0
  60. data/spec/dsl/dsl_spec.rb +298 -0
  61. data/spec/dsl/project_spec.rb +266 -0
  62. data/spec/fixtures/app-dependencies-dockerfile +25 -0
  63. data/spec/fixtures/database-dockerfile +31 -0
  64. data/spec/fixtures/deploy-dockerfile +2 -0
  65. data/spec/fixtures/mars-dockerfile +32 -0
  66. data/spec/fixtures/multi-project-web-dockerfile +35 -0
  67. data/spec/fixtures/web-dockerfile +27 -0
  68. data/spec/runner/build_images_spec.rb +164 -0
  69. data/spec/runner/build_spec.rb +86 -0
  70. data/spec/runner/checkout_spec.rb +128 -0
  71. data/spec/runner/command_spec.rb +94 -0
  72. data/spec/runner/help_spec.rb +73 -0
  73. data/spec/runner/implode_spec.rb +62 -0
  74. data/spec/runner/run_containers_spec.rb +141 -0
  75. data/spec/runner/runner_spec.rb +117 -0
  76. data/spec/runner/services_spec.rb +135 -0
  77. data/spec/runner/shell_spec.rb +123 -0
  78. data/spec/runner/update_hosts_spec.rb +163 -0
  79. data/spec/spec_helper.rb +10 -0
  80. data/spec/support/docker_stubbing.rb +93 -0
  81. data/spec/support/test_project.rb +56 -0
  82. metadata +193 -0
@@ -0,0 +1,298 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ module RubyYacht::DSL::Base::ClassMethods
5
+ def clear
6
+ @required_attributes = []
7
+ @all_attributes = []
8
+ @default_values = {}
9
+ @copied_attributes = nil
10
+ @created_type = nil
11
+ end
12
+ end
13
+
14
+ module DSLTestHelpers
15
+ class ThingOne
16
+ attr_accessor :name
17
+ attr_accessor :size
18
+ end
19
+
20
+ class ThingTwo
21
+ attr_accessor :name
22
+ attr_accessor :color
23
+ end
24
+
25
+ class DSL
26
+ extend RubyYacht::DSL::Base::ClassMethods
27
+ include RubyYacht::DSL::Base
28
+ end
29
+
30
+ class SecondDSL
31
+ extend RubyYacht::DSL::Base::ClassMethods
32
+ include RubyYacht::DSL::Base
33
+ end
34
+ end
35
+ describe RubyYacht::DSL::Base do
36
+ let(:DSL) { DSLTestHelpers::DSL }
37
+ let(:SecondDSL) { DSLTestHelpers::SecondDSL }
38
+
39
+ before do
40
+ DSLTestHelpers::DSL.clear
41
+ DSLTestHelpers::SecondDSL.clear
42
+ end
43
+
44
+ def run_dsl(&block)
45
+ dsl = DSLTestHelpers::DSL.new
46
+ dsl.run(block)
47
+ dsl
48
+ end
49
+
50
+ describe "add_generic_attribute" do
51
+ it "adds the attribute to the list" do
52
+ DSLTestHelpers::DSL.add_generic_attribute :namify, :name do | value|
53
+ end
54
+
55
+ expect(DSLTestHelpers::DSL.all_attributes).to eq [:name]
56
+ expect(DSLTestHelpers::DSL.required_attributes).to eq [:name]
57
+ expect(DSLTestHelpers::DSL.default_values).to eq({})
58
+ end
59
+
60
+ it "defines a method with the method name provided" do
61
+ capture = nil
62
+ DSLTestHelpers::DSL.add_generic_attribute :namify, :name do | value|
63
+ capture = value
64
+ end
65
+
66
+ run_dsl do
67
+ namify 'foo'
68
+ end
69
+ expect(capture).to eq 'foo'
70
+ end
71
+
72
+ it "can accept optional fields" do
73
+ DSLTestHelpers::DSL.add_generic_attribute :namify, :name, nil, false do | value|
74
+ end
75
+
76
+ expect(DSLTestHelpers::DSL.all_attributes).to eq [:name]
77
+ expect(DSLTestHelpers::DSL.required_attributes).to eq []
78
+ end
79
+
80
+ it "can accept fields with default values" do
81
+ DSLTestHelpers::DSL.add_generic_attribute :namify, :name, 'hello' do | value|
82
+ end
83
+
84
+ expect(DSLTestHelpers::DSL.all_attributes).to eq [:name]
85
+ expect(DSLTestHelpers::DSL.default_values).to eq(name: 'hello')
86
+ end
87
+ end
88
+
89
+ describe "add_attribute" do
90
+ before do
91
+ DSLTestHelpers::DSL.add_attribute :name
92
+ end
93
+
94
+ it "defines a method for setting the attribute" do
95
+ dsl = run_dsl do
96
+ name 'hi'
97
+ end
98
+ expect(dsl.instance_eval { @name }).to eq 'hi'
99
+ end
100
+
101
+ it "makes the field required" do
102
+ expect(DSLTestHelpers::DSL.required_attributes).to eq [:name]
103
+ end
104
+
105
+ it "can accept default values" do
106
+ DSLTestHelpers::DSL.clear
107
+ DSLTestHelpers::DSL.add_attribute :name, 'test'
108
+ dsl = run_dsl {}
109
+ expect(dsl.instance_eval { @name }).to eq 'test'
110
+ end
111
+
112
+ it "replaces the value when called multiple times" do
113
+ dsl = run_dsl do
114
+ name 'name1'
115
+ name 'name2'
116
+ end
117
+ expect(dsl.instance_eval { @name }).to eq 'name2'
118
+ end
119
+ end
120
+
121
+ describe "add_list" do
122
+ before do
123
+ DSLTestHelpers::DSL.add_list :hat
124
+ end
125
+
126
+ it "defines a methods for capturing values in a list" do
127
+ dsl = run_dsl do
128
+ hat 'red'
129
+ hat 'black'
130
+ end
131
+
132
+ expect(dsl.instance_eval { @hats }).to eq ['red', 'black']
133
+ end
134
+
135
+ it "gives an empty list when the method is not called" do
136
+ dsl = run_dsl {}
137
+
138
+ expect(dsl.instance_eval { @hats }).to eq []
139
+ end
140
+ end
141
+
142
+ describe "add_boolean" do
143
+ before do
144
+ DSLTestHelpers::DSL.add_boolean :break_the_rules
145
+ end
146
+
147
+ it "defines a method for setting the flag to true" do
148
+ dsl = run_dsl do
149
+ break_the_rules
150
+ end
151
+ expect(dsl.instance_eval { @break_the_rules }).to be_truthy
152
+ end
153
+
154
+ it "leaves the flag false by default" do
155
+ dsl = run_dsl {}
156
+ expect(dsl.instance_eval { @break_the_rules }).to be_falsey
157
+ end
158
+ end
159
+
160
+ describe "add_object" do
161
+ before do
162
+ DSLTestHelpers::SecondDSL.add_attribute :name
163
+ DSLTestHelpers::SecondDSL.creates_object DSLTestHelpers::ThingOne
164
+ DSLTestHelpers::DSL.add_object :thing, 'DSLTestHelpers::SecondDSL'
165
+ end
166
+
167
+ it "defines a method for constructing an object of the real type" do
168
+ dsl = run_dsl do
169
+ thing do
170
+ name 'Charlie'
171
+ end
172
+ end
173
+
174
+ thing = dsl.instance_eval { @thing }
175
+ expect(thing).to be_a DSLTestHelpers::ThingOne
176
+ expect(thing.name).to eq 'Charlie'
177
+ end
178
+
179
+ it "makes the object required by default" do
180
+ expect(DSLTestHelpers::DSL.required_attributes).to eq [:thing]
181
+ end
182
+
183
+ it "can accept optional attributes" do
184
+ DSLTestHelpers::DSL.clear
185
+ DSLTestHelpers::DSL.add_object :thing, 'DSLTestHelpers::SecondDSL', required: false
186
+ expect(DSLTestHelpers::DSL.required_attributes).to eq []
187
+ end
188
+ end
189
+
190
+ describe "add_object_list" do
191
+ before do
192
+ DSLTestHelpers::SecondDSL.add_attribute :name
193
+ DSLTestHelpers::SecondDSL.creates_object DSLTestHelpers::ThingOne
194
+ DSLTestHelpers::DSL.add_object_list :thing, 'DSLTestHelpers::SecondDSL'
195
+ end
196
+
197
+ it "defines methods for building a list of objects" do
198
+ dsl = run_dsl do
199
+ thing do
200
+ name 'Jim'
201
+ end
202
+
203
+ thing do
204
+ name 'Bob'
205
+ end
206
+ end
207
+
208
+ things = dsl.instance_eval { @things }
209
+ expect(things.count).to eq 2
210
+ expect(things[0]).to be_a DSLTestHelpers::ThingOne
211
+ expect(things[0].name).to eq 'Jim'
212
+ expect(things[1]).to be_a DSLTestHelpers::ThingOne
213
+ expect(things[1].name).to eq 'Bob'
214
+ end
215
+
216
+ it "gives an empty list as the default value" do
217
+ dsl = run_dsl {}
218
+ expect(dsl.instance_eval { @things }).to eq []
219
+ end
220
+ end
221
+
222
+ describe "creates_object" do
223
+ it "sets the copied attributes and created type" do
224
+ DSLTestHelpers::DSL.creates_object DSLTestHelpers::ThingOne, [:name, :size]
225
+ expect(DSLTestHelpers::DSL.created_type).to eq DSLTestHelpers::ThingOne
226
+ expect(DSLTestHelpers::DSL.copied_attributes).to eq [:name, :size]
227
+ end
228
+
229
+ it "uses the full list of attributes as the copied attributes by default" do
230
+ DSLTestHelpers::DSL.add_attribute :name
231
+ DSLTestHelpers::DSL.add_attribute :color
232
+ DSLTestHelpers::DSL.creates_object DSLTestHelpers::ThingOne
233
+ expect(DSLTestHelpers::DSL.created_type).to eq DSLTestHelpers::ThingOne
234
+ expect(DSLTestHelpers::DSL.copied_attributes).to eq [:name, :color]
235
+ end
236
+ end
237
+
238
+ describe "run" do
239
+ it "does not modify the defaults when called multiple times" do
240
+ DSLTestHelpers::DSL.add_list :thing
241
+ case1 = run_dsl do
242
+ thing 'a'
243
+ thing 'b'
244
+ end
245
+
246
+ case2 = run_dsl do
247
+ thing 'c'
248
+ end
249
+
250
+ case3 = run_dsl {}
251
+
252
+ expect(case1.instance_eval { @things }).to eq ['a', 'b']
253
+ expect(case2.instance_eval { @things }).to eq ['c']
254
+ expect(case3.instance_eval { @things }).to eq []
255
+ end
256
+ end
257
+
258
+ describe "check_required_attributes" do
259
+ before do
260
+ DSLTestHelpers::DSL.add_attribute :name
261
+ DSLTestHelpers::DSL.add_attribute :size, nil, false
262
+ end
263
+
264
+ it "does not throw an exception when all attributes are set" do
265
+ dsl = DSLTestHelpers::DSL.new
266
+ dsl.run(Proc.new do
267
+ name 'Jim'
268
+ size 10
269
+ end)
270
+ expect(lambda { dsl.check_required_attributes}).not_to raise_exception
271
+ end
272
+
273
+ it "does not throw an exception when an optional attribute is missing" do
274
+ dsl = DSLTestHelpers::DSL.new
275
+ dsl.run(Proc.new do
276
+ name 'Jim'
277
+ end)
278
+ expect(lambda { dsl.check_required_attributes}).not_to raise_exception
279
+ end
280
+
281
+ it "throws an exception when a required attribute is nil" do
282
+ dsl = DSLTestHelpers::DSL.new
283
+ dsl.run(Proc.new do
284
+ size 10
285
+ end)
286
+ expect(lambda { dsl.check_required_attributes}).to raise_exception 'Missing required attribute name for DSLTestHelpers::DSL'
287
+ end
288
+
289
+ it "throws an exception when a required attribute is an empty string" do
290
+ dsl = DSLTestHelpers::DSL.new
291
+ dsl.run(Proc.new do
292
+ name ''
293
+ size 10
294
+ end)
295
+ expect(lambda { dsl.check_required_attributes}).to raise_exception 'Missing required attribute name for DSLTestHelpers::DSL'
296
+ end
297
+ end
298
+ end
@@ -0,0 +1,266 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyYacht::Project do
4
+ describe "dsl" do
5
+ let(:project) { RubyYacht::Project::DSL.new(:test_project).run(@builder).create_object }
6
+
7
+ it "can create a project with all the fields" do
8
+ @builder = Proc.new do
9
+ system_prefix :a
10
+ domain "a.test.com"
11
+ secret_key_base "a"
12
+ repository "github.com"
13
+ rails_environment "production"
14
+
15
+ app(:app1) do
16
+ repository_name 'brownleej/test1'
17
+ end
18
+
19
+ app(:app2) do
20
+ repository_name 'brownleej/test2'
21
+ end
22
+
23
+ database do
24
+ host "localhost"
25
+ name "project1"
26
+ username "test"
27
+ password "test"
28
+ end
29
+
30
+ dns_server do
31
+ server '8.10.1.1'
32
+ end
33
+ end
34
+
35
+ expect(project.name).to eq :test_project
36
+ expect(project.system_prefix).to eq :a
37
+ expect(project.domain).to eq "a.test.com"
38
+ expect(project.secret_key_base).to eq "a"
39
+ expect(project.repository).to eq "github.com"
40
+ expect(project.rails_environment).to eq "production"
41
+
42
+ expect(project.apps.map(&:name)).to eq [:app1, :app2]
43
+ expect(project.database.name).to eq 'project1'
44
+ expect(project.dns_server.servers).to eq ['8.10.1.1']
45
+ end
46
+
47
+ it "requires the system prefix" do
48
+ @builder = Proc.new do
49
+ domain "a.test.com"
50
+ secret_key_base "a"
51
+ repository "github.com"
52
+
53
+ app(:app1) do
54
+ repository_name 'brownleej/test1'
55
+ end
56
+
57
+ app(:app2) do
58
+ repository_name 'brownleej/test2'
59
+ end
60
+
61
+ database do
62
+ host "localhost"
63
+ name "project1"
64
+ username "test"
65
+ password "test"
66
+ end
67
+
68
+ dns_server do
69
+ server '8.10.1.1'
70
+ end
71
+ end
72
+
73
+ expect { project }.to raise_exception "Missing required attribute system_prefix for RubyYacht::Project::DSL"
74
+ end
75
+
76
+ it "requires the domain" do
77
+ @builder = Proc.new do
78
+ system_prefix :a
79
+ secret_key_base "a"
80
+ repository "github.com"
81
+
82
+ app(:app1) do
83
+ repository_name 'brownleej/test1'
84
+ end
85
+
86
+ app(:app2) do
87
+ repository_name 'brownleej/test2'
88
+ end
89
+
90
+ database do
91
+ host "localhost"
92
+ name "project1"
93
+ username "test"
94
+ password "test"
95
+ end
96
+
97
+ dns_server do
98
+ server '8.10.1.1'
99
+ end
100
+ end
101
+
102
+ expect { project }.to raise_exception "Missing required attribute domain for RubyYacht::Project::DSL"
103
+ end
104
+
105
+ it "requires the secret_key_base" do
106
+ @builder = Proc.new do
107
+ system_prefix :a
108
+ domain "a.test.com"
109
+ repository "github.com"
110
+
111
+ app(:app1) do
112
+ repository_name 'brownleej/test1'
113
+ end
114
+
115
+ app(:app2) do
116
+ repository_name 'brownleej/test2'
117
+ end
118
+
119
+ database do
120
+ host "localhost"
121
+ name "project1"
122
+ username "test"
123
+ password "test"
124
+ end
125
+
126
+ dns_server do
127
+ server '8.10.1.1'
128
+ end
129
+ end
130
+
131
+ expect { project }.to raise_exception "Missing required attribute secret_key_base for RubyYacht::Project::DSL"
132
+ end
133
+
134
+ it "requires the repository" do
135
+ @builder = Proc.new do
136
+ system_prefix :a
137
+ domain "a.test.com"
138
+ secret_key_base "a"
139
+
140
+ app(:app1) do
141
+ repository_name 'brownleej/test1'
142
+ end
143
+
144
+ app(:app2) do
145
+ repository_name 'brownleej/test2'
146
+ end
147
+
148
+ database do
149
+ host "localhost"
150
+ name "project1"
151
+ username "test"
152
+ password "test"
153
+ end
154
+
155
+ dns_server do
156
+ server '8.10.1.1'
157
+ end
158
+ end
159
+
160
+ expect { project }.to raise_exception "Missing required attribute repository for RubyYacht::Project::DSL"
161
+ end
162
+ it "defaults the rails_environment to development" do
163
+ @builder = Proc.new do
164
+ system_prefix :a
165
+ domain "a.test.com"
166
+ secret_key_base "a"
167
+ repository "github.com"
168
+
169
+ app(:app1) do
170
+ repository_name 'brownleej/test1'
171
+ end
172
+
173
+ app(:app2) do
174
+ repository_name 'brownleej/test2'
175
+ end
176
+
177
+ database do
178
+ host "localhost"
179
+ name "project1"
180
+ username "test"
181
+ password "test"
182
+ end
183
+
184
+ dns_server do
185
+ server '8.10.1.1'
186
+ end
187
+ end
188
+
189
+ expect(project.rails_environment).to eq 'development'
190
+ end
191
+
192
+ it "does not require any apps" do
193
+ @builder = Proc.new do
194
+ system_prefix :a
195
+ domain "a.test.com"
196
+ secret_key_base "a"
197
+ repository "github.com"
198
+ rails_environment "production"
199
+
200
+ database do
201
+ host "localhost"
202
+ name "project1"
203
+ username "test"
204
+ password "test"
205
+ end
206
+
207
+ dns_server do
208
+ server '8.10.1.1'
209
+ end
210
+ end
211
+
212
+ expect(project.apps.count).to eq 0
213
+ end
214
+
215
+ it "requires the database config" do
216
+ @builder = Proc.new do
217
+ system_prefix :a
218
+ domain "a.test.com"
219
+ secret_key_base "a"
220
+ repository "github.com"
221
+ rails_environment "production"
222
+
223
+ app(:app1) do
224
+ repository_name 'brownleej/test1'
225
+ end
226
+
227
+ app(:app2) do
228
+ repository_name 'brownleej/test2'
229
+ end
230
+
231
+ dns_server do
232
+ server '8.10.1.1'
233
+ end
234
+ end
235
+
236
+ expect { project }.to raise_exception "Missing required attribute database for RubyYacht::Project::DSL"
237
+ end
238
+
239
+ it "does not require the DNS server config" do
240
+ @builder = Proc.new do
241
+ system_prefix :a
242
+ domain "a.test.com"
243
+ secret_key_base "a"
244
+ repository "github.com"
245
+ rails_environment "production"
246
+
247
+ app(:app1) do
248
+ repository_name 'brownleej/test1'
249
+ end
250
+
251
+ app(:app2) do
252
+ repository_name 'brownleej/test2'
253
+ end
254
+
255
+ database do
256
+ host "localhost"
257
+ name "project1"
258
+ username "test"
259
+ password "test"
260
+ end
261
+ end
262
+
263
+ expect(project.dns_server).to be_nil
264
+ end
265
+ end
266
+ end
@@ -0,0 +1,25 @@
1
+ # This Dockerfile creates an image for installing all of the gem dependencies
2
+ # for all of the apps.
3
+ #
4
+ # This is a slow process, so this should be kept as simple as possible so that
5
+ # it can remain unchanged.
6
+
7
+ FROM ruby:2.3
8
+
9
+ RUN mkdir -p /root/.ssh
10
+ COPY id_rsa /root/.ssh
11
+ RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
12
+
13
+ RUN mkdir -p /var/docker/
14
+ COPY install_gems.rb /var/docker/install_gems.rb
15
+
16
+
17
+ RUN ruby /var/docker/install_gems.rb mars github.com brownleej/mars
18
+
19
+ RUN ruby /var/docker/install_gems.rb saturn github.com brownleej/saturn
20
+
21
+
22
+ RUN rm /var/docker/install_gems.rb
23
+
24
+ RUN apt-get update && apt-get upgrade -y
25
+ RUN apt-get install -y mysql-client
@@ -0,0 +1,31 @@
1
+ FROM apollo-app-dependencies
2
+
3
+
4
+
5
+ ENV DEBIAN_FRONTEND noninteractive
6
+ RUN apt-get install -y mysql-server
7
+
8
+ COPY setup.rb /var/docker/setup.rb
9
+ COPY setup_database.sql.erb /var/docker/setup_database.sql.erb
10
+ COPY load_seeds.rb /var/docker/load_seeds.rb
11
+
12
+ RUN ruby /var/docker/setup.rb apollo apollo test development
13
+
14
+
15
+
16
+
17
+
18
+ RUN ruby /var/docker/load_seeds.rb mars apollo_development apollo test false
19
+
20
+
21
+
22
+
23
+ RUN ruby /var/docker/load_seeds.rb saturn apollo_development apollo test true
24
+
25
+
26
+ RUN rm -r /var/docker
27
+ RUN rm -r /var/code
28
+
29
+ EXPOSE 3306
30
+
31
+ CMD mysqld_safe --bind-address=0.0.0.0
@@ -0,0 +1,2 @@
1
+ FROM apollo-app-dependencies
2
+ CMD bash
@@ -0,0 +1,32 @@
1
+ FROM apollo-app-dependencies
2
+
3
+ ENV DATABASE_HOST db.test.com
4
+ ENV DATABASE_NAME apollo
5
+ ENV DATABASE_PASSWORD test
6
+ ENV DATABASE_USERNAME apollo
7
+ ENV RAILS_ENV development
8
+ ENV RAILS_PORT 8080
9
+ ENV REPOSITORY_HOST github.com
10
+ ENV SECRET_KEY_BASE abc
11
+ ENV SYSTEM_PREFIX apollo
12
+
13
+ RUN rm -r /var/code
14
+ RUN mkdir -p /var/code
15
+
16
+ COPY startup.rb /var/docker/startup.rb
17
+ COPY checkout.rb /var/docker/checkout.rb
18
+ COPY update_database_config.rb /var/docker/update_database_config.rb
19
+
20
+ RUN chmod u+x /var/docker/*.rb
21
+
22
+ ENV REPOSITORY_NAME brownleej/mars
23
+
24
+ RUN /var/docker/checkout.rb
25
+
26
+ WORKDIR /var/code
27
+
28
+ RUN bundle install && bundle clean --force
29
+
30
+ EXPOSE 8080
31
+
32
+ CMD /var/docker/startup.rb
@@ -0,0 +1,35 @@
1
+ FROM nginx
2
+
3
+ RUN apt-get update
4
+ RUN apt-get upgrade -y
5
+ RUN apt-get install -y ruby
6
+
7
+ RUN mkdir -p /var/docker
8
+
9
+ COPY add_project.rb /var/docker/add_project.rb
10
+ COPY add_app.rb /var/docker/add_app.rb
11
+ COPY index.html.erb /var/docker/index.html.erb
12
+ COPY index_config.erb /var/docker/index_config.erb
13
+ COPY app_config.erb /var/docker/app_config.erb
14
+
15
+
16
+
17
+ RUN ruby /var/docker/add_project.rb apollo apollo.test.com mars,saturn
18
+
19
+ RUN ruby /var/docker/add_app.rb apollo apollo.test.com mars 8080
20
+
21
+ RUN ruby /var/docker/add_app.rb apollo apollo.test.com saturn 8080
22
+
23
+
24
+
25
+ RUN ruby /var/docker/add_project.rb jupiter jupiter.test.com venus,saturn
26
+
27
+ RUN ruby /var/docker/add_app.rb jupiter jupiter.test.com venus 8080
28
+
29
+ RUN ruby /var/docker/add_app.rb jupiter jupiter.test.com saturn 8080
30
+
31
+
32
+
33
+ RUN rm -r /var/docker
34
+ RUN apt-get remove -y ruby
35
+ RUN apt-get autoremove -y