orchestration 0.5.9 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -5
- data/lib/orchestration/docker_compose/app_service.rb +7 -1
- data/lib/orchestration/docker_compose/configuration.rb +2 -2
- data/lib/orchestration/docker_compose/install_generator.rb +1 -1
- data/lib/orchestration/docker_compose/rabbitmq_service.rb +4 -2
- data/lib/orchestration/environment.rb +1 -1
- data/lib/orchestration/errors.rb +2 -0
- data/lib/orchestration/service_check.rb +2 -2
- data/lib/orchestration/services/database/adapters/mysql2.rb +2 -2
- data/lib/orchestration/services/database/configuration.rb +12 -18
- data/lib/orchestration/services/rabbitmq.rb +1 -0
- data/lib/orchestration/templates/env.erb +0 -2
- data/lib/orchestration/templates/orchestration.mk.erb +2 -4
- data/lib/orchestration/templates/puma.rb.erb +1 -1
- data/lib/orchestration/templates/rabbitmq.yml.erb +5 -2
- data/lib/orchestration/version.rb +1 -1
- data/orchestration.gemspec +5 -3
- metadata +51 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 291252425784215fed686a5bf414b115dbec55ebca6bcdb23b136d5c6816e195
|
4
|
+
data.tar.gz: d972df8f59a94eca1912911b4f662fc195fa154efe935d5b4c55aef41c7b61c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8628b095acf09db5f22f9144c4224fdbd3b97d16b737c3269e9ba3db04ca5c91574c926f6ea6382d4e6daea8248a7e297dc81dba06d1a1818077584a1955bd9a
|
7
|
+
data.tar.gz: 666c46c274e7fe26828e35b2eaa0ff8455b3c6866611e91572f7ad08daff1476985944b41ccf2e6c37b02294256deb9739f1c8413308e72509b0baab6b815e56
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
|
|
27
27
|
Add _Orchestration_ to your Gemfile:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
gem 'orchestration', '~> 0.5.
|
30
|
+
gem 'orchestration', '~> 0.5.14'
|
31
31
|
```
|
32
32
|
|
33
33
|
Install:
|
@@ -191,12 +191,20 @@ make serve server='-p 3001 -b 192.168.0.1'
|
|
191
191
|
A default `test` target is provided in your application's main `Makefile`. You are encouraged to modify this target to suit your application's requirements.
|
192
192
|
|
193
193
|
To launch all dependency containers, run database migrations, and run tests:
|
194
|
-
```
|
194
|
+
```bash
|
195
195
|
make test
|
196
196
|
```
|
197
197
|
|
198
|
-
|
198
|
+
The default `test` command can (and should) be extended. This command is defined in the root `Makefile` in the project and, by defaults, runs `rspec` and `rubocop`.
|
199
|
+
|
200
|
+
To run only the `test` command, without test setup (i.e. without restarting containers etc.), pass the `light` option:
|
201
|
+
|
202
|
+
```bash
|
203
|
+
make test light=1
|
199
204
|
```
|
205
|
+
|
206
|
+
If you prefer to run tests manually (e.g. if you want to run tests for a specific file) then the `test-setup` target can be used:
|
207
|
+
```bash
|
200
208
|
make test-setup
|
201
209
|
bundle exec rspec spec/my_class_spec.rb
|
202
210
|
```
|
@@ -208,8 +216,8 @@ _(See [sidecar containers](#sidecar-containers) if you are running your test/dev
|
|
208
216
|
Dependencies will be launched and then tested for readiness. The retry limit and interval time for readiness tests can be controlled by the following environment variables:
|
209
217
|
|
210
218
|
```
|
211
|
-
ORCHESTRATION_RETRY_LIMIT # default:
|
212
|
-
ORCHESTRATION_RETRY_INTERVAL # default:
|
219
|
+
ORCHESTRATION_RETRY_LIMIT # default: 15
|
220
|
+
ORCHESTRATION_RETRY_INTERVAL # default: 10 [seconds]
|
213
221
|
```
|
214
222
|
|
215
223
|
### (Local) Production
|
@@ -394,12 +402,15 @@ _Orchestration_ generates the following `config/rabbitmq.yml`:
|
|
394
402
|
```
|
395
403
|
development:
|
396
404
|
url: amqp://127.0.0.1:51070
|
405
|
+
management_url: http://127.0.0.1:5069
|
397
406
|
|
398
407
|
test:
|
399
408
|
url: amqp://127.0.0.1:51068
|
409
|
+
management_url: http://127.0.0.1:5067
|
400
410
|
|
401
411
|
production:
|
402
412
|
url: <%= ENV['RABBITMQ_URL'] %>
|
413
|
+
management_url: <%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
|
403
414
|
```
|
404
415
|
|
405
416
|
Using this approach, the environment variable `RABBITMQ_URL` can be used to configure _Bunny_ in production (similar to `DATABASE_URL` and `MONGO_URL`).
|
@@ -100,7 +100,13 @@ module Orchestration
|
|
100
100
|
'WEB_PRELOAD_APP' => '1',
|
101
101
|
'WEB_HEALTHCHECK_PATH' => '/',
|
102
102
|
'DATABASE_URL' => database_url
|
103
|
-
}.merge(
|
103
|
+
}.merge(inherited_environment.map { |key| [key, nil] }.to_h).merge(rabbitmq_urls)
|
104
|
+
end
|
105
|
+
|
106
|
+
def rabbitmq_urls
|
107
|
+
return {} unless Services::RabbitMQ::Configuration.new(Environment.new).enabled?
|
108
|
+
|
109
|
+
{ 'RABBITMQ_URL' => 'amqp://rabbitmq:5672', 'RABBITMQ_MANAGEMENT_URL' => 'http://rabbitmq:15672' }
|
104
110
|
end
|
105
111
|
|
106
112
|
def database_url
|
@@ -14,7 +14,7 @@ module Orchestration
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def services
|
17
|
-
|
17
|
+
services_enabled.to_h
|
18
18
|
end
|
19
19
|
|
20
20
|
def volumes
|
@@ -62,7 +62,7 @@ module Orchestration
|
|
62
62
|
.fetch(service)
|
63
63
|
.new(config, @environment)
|
64
64
|
.definition
|
65
|
-
&.
|
65
|
+
&.tap { |definition| definition['networks'] ||= { 'local' => {} } }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -13,15 +13,17 @@ module Orchestration
|
|
13
13
|
def definition
|
14
14
|
return nil unless @config.enabled?
|
15
15
|
|
16
|
-
{ 'image' => 'library/rabbitmq' }.merge(ports)
|
16
|
+
{ 'image' => 'library/rabbitmq:management' }.merge(ports)
|
17
17
|
end
|
18
18
|
|
19
19
|
def ports
|
20
20
|
return {} unless %i[development test].include?(@environment)
|
21
21
|
|
22
22
|
container_port = Orchestration::Services::RabbitMQ::PORT
|
23
|
+
management_port = Orchestration::Services::RabbitMQ::MANAGEMENT_PORT
|
23
24
|
|
24
|
-
{ 'ports' => ["#{sidecar_port(@environment)}#{container_port}"
|
25
|
+
{ 'ports' => ["#{sidecar_port(@environment)}#{container_port}",
|
26
|
+
"#{sidecar_port(@environment)}#{management_port}"] }
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -129,7 +129,7 @@ module Orchestration
|
|
129
129
|
def docker_filter(string)
|
130
130
|
# Filter out characters not accepted by Docker Hub
|
131
131
|
permitted = [('0'..'9'), ('a'..'z')].map(&:to_a).flatten
|
132
|
-
string.
|
132
|
+
string.chars.select { |char| permitted.include?(char) }.join
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
data/lib/orchestration/errors.rb
CHANGED
@@ -4,7 +4,9 @@ module Orchestration
|
|
4
4
|
class OrchestrationError < StandardError; end
|
5
5
|
|
6
6
|
class HTTPConnectionError < OrchestrationError; end
|
7
|
+
|
7
8
|
class DatabaseConfigurationError < OrchestrationError; end
|
9
|
+
|
8
10
|
class MongoConfigurationError < OrchestrationError; end
|
9
11
|
|
10
12
|
class UnknownEnvironmentError < DatabaseConfigurationError; end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Orchestration
|
4
4
|
class ServiceCheck
|
5
|
-
ATTEMPT_LIMIT = ENV.fetch('ORCHESTRATION_RETRY_LIMIT', '
|
6
|
-
RETRY_INTERVAL = ENV.fetch('ORCHESTRATION_RETRY_INTERVAL', '
|
5
|
+
ATTEMPT_LIMIT = ENV.fetch('ORCHESTRATION_RETRY_LIMIT', '15').to_i
|
6
|
+
RETRY_INTERVAL = ENV.fetch('ORCHESTRATION_RETRY_INTERVAL', '10').to_i
|
7
7
|
|
8
8
|
def initialize(service, terminal, options = {})
|
9
9
|
@service = service
|
@@ -10,7 +10,7 @@ module Orchestration
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def image
|
13
|
-
return
|
13
|
+
return mysql57 if gem_version < Gem::Version.new('0.4')
|
14
14
|
|
15
15
|
'library/mysql'
|
16
16
|
end
|
@@ -43,7 +43,7 @@ module Orchestration
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def
|
46
|
+
def mysql57
|
47
47
|
'library/mysql:5.7'
|
48
48
|
end
|
49
49
|
|
@@ -15,7 +15,7 @@ module Orchestration
|
|
15
15
|
def friendly_config
|
16
16
|
return "[#{adapter.name}]" if sqlite?
|
17
17
|
|
18
|
-
"[#{adapter.name}] #{host}:#{port}"
|
18
|
+
"[#{adapter.name}] #{adapter.name}://#{username}:#{password}@#{host}:#{port}/#{database}"
|
19
19
|
end
|
20
20
|
|
21
21
|
def settings(healthcheck: false)
|
@@ -82,37 +82,31 @@ module Orchestration
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def host
|
85
|
-
|
85
|
+
chained_config('host') || super
|
86
86
|
end
|
87
87
|
|
88
88
|
def port
|
89
89
|
return nil if sqlite?
|
90
90
|
|
91
|
-
|
91
|
+
chained_config('port') || super
|
92
92
|
end
|
93
93
|
|
94
94
|
def username
|
95
|
-
(
|
96
|
-
url_config['username'] ||
|
97
|
-
file_config['username'] ||
|
98
|
-
(adapter && adapter.credentials['username'])
|
99
|
-
)
|
95
|
+
chained_config('username') || (adapter && adapter.credentials['username'])
|
100
96
|
end
|
101
97
|
|
102
98
|
def password
|
103
|
-
(
|
104
|
-
url_config['password'] ||
|
105
|
-
file_config['password'] ||
|
106
|
-
(adapter && adapter.credentials['password'])
|
107
|
-
)
|
99
|
+
chained_config('password') || (adapter && adapter.credentials['password'])
|
108
100
|
end
|
109
101
|
|
110
102
|
def database
|
111
|
-
(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
103
|
+
chained_config('database') || (adapter && adapter.credentials['database'])
|
104
|
+
end
|
105
|
+
|
106
|
+
def chained_config(key)
|
107
|
+
return url_config[key] || file_config[key] if @env.environment == 'test'
|
108
|
+
|
109
|
+
file_config[key] || url_config[key]
|
116
110
|
end
|
117
111
|
|
118
112
|
def adapter_by_name(name)
|
@@ -112,7 +112,7 @@ all: build
|
|
112
112
|
|
113
113
|
.PHONY: start
|
114
114
|
ifndef network
|
115
|
-
start: network := ${compose_project_name}
|
115
|
+
start: network := ${compose_project_name}
|
116
116
|
endif
|
117
117
|
start: _create-log-directory _clean-logs
|
118
118
|
@$(call print,'${yellow}Starting ${cyan}${env}${yellow} containers${reset} ...')
|
@@ -144,7 +144,7 @@ start-<%= service %>:
|
|
144
144
|
<% end %>
|
145
145
|
|
146
146
|
.PHONY: stop
|
147
|
-
stop: network := ${compose_project_name}
|
147
|
+
stop: network := ${compose_project_name}
|
148
148
|
stop:
|
149
149
|
@$(call print,'${yellow}Stopping ${cyan}${env}${yellow} containers${reset} ...')
|
150
150
|
@if docker ps --format "{{.ID}}" | grep -q $(shell hostname) ; \
|
@@ -238,7 +238,6 @@ ifndef verbose
|
|
238
238
|
$(call hr,${red}) ; \
|
239
239
|
)
|
240
240
|
endif
|
241
|
-
ifneq (,$(findstring deploy,$(MAKECMDGOALS)))
|
242
241
|
@echo ; \
|
243
242
|
$(call hr,${yellow}) ; \
|
244
243
|
$(call println,'${gray}docker-compose logs${reset}') ; \
|
@@ -247,7 +246,6 @@ ifneq (,$(findstring deploy,$(MAKECMDGOALS)))
|
|
247
246
|
@${compose} logs
|
248
247
|
@echo ; \
|
249
248
|
$(call hr,${yellow})
|
250
|
-
endif
|
251
249
|
@$(NOOP)
|
252
250
|
|
253
251
|
.PHONY: image
|
@@ -1,12 +1,15 @@
|
|
1
1
|
<% if compose.call('development').services.key?('rabbitmq') %>
|
2
2
|
development:
|
3
|
-
url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('development').local_port('rabbitmq')}') #{'%' + '>'}" %>
|
3
|
+
url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('development').local_port('rabbitmq', 5672)}') #{'%' + '>'}" %>
|
4
|
+
management_url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_MANAGEMENT_URL', 'http://guest:guest@127.0.0.1:#{compose.call('development').local_port('rabbitmq', 15672)}') #{'%' + '>'}" %>
|
4
5
|
<% end %>
|
5
6
|
|
6
7
|
<% if compose.call('test').services.key?('rabbitmq') %>
|
7
8
|
test:
|
8
|
-
url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('test').local_port('rabbitmq')}') #{'%' + '>'}" %>
|
9
|
+
url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_URL', 'amqp://127.0.0.1:#{compose.call('test').local_port('rabbitmq', 5672)}') #{'%' + '>'}" %>
|
10
|
+
management_url: <%= "#{'<' + '%' + '='} ENV.fetch('RABBITMQ_MANAGEMENT_URL', 'http://guest:guest@127.0.0.1:#{compose.call('test').local_port('rabbitmq', 15672)}') #{'%' + '>'}" %>
|
9
11
|
<% end %>
|
10
12
|
|
11
13
|
production:
|
12
14
|
url: <%%= ENV['RABBITMQ_URL'] %>
|
15
|
+
url: <%%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
|
data/orchestration.gemspec
CHANGED
@@ -33,9 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_runtime_dependency 'thor', '~> 1.0'
|
34
34
|
|
35
35
|
spec.add_development_dependency 'activerecord', '~> 6.0'
|
36
|
-
spec.add_development_dependency 'bundler', '~> 1.16'
|
37
36
|
spec.add_development_dependency 'bunny', '~> 2.12'
|
38
|
-
spec.add_development_dependency 'devpack', '~> 0.3.
|
37
|
+
spec.add_development_dependency 'devpack', '~> 0.3.2'
|
39
38
|
spec.add_development_dependency 'mongoid', '~> 7.0'
|
40
39
|
spec.add_development_dependency 'mysql2', '~> 0.5.2'
|
41
40
|
spec.add_development_dependency 'pg', '~> 1.1'
|
@@ -43,7 +42,10 @@ Gem::Specification.new do |spec|
|
|
43
42
|
spec.add_development_dependency 'rake', '~> 10.0'
|
44
43
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
45
44
|
spec.add_development_dependency 'rspec-its', '~> 1.2'
|
46
|
-
spec.add_development_dependency 'rubocop', '~>
|
45
|
+
spec.add_development_dependency 'rubocop', '~> 1.12'
|
46
|
+
spec.add_development_dependency 'rubocop-rails', '~> 2.9'
|
47
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.5.1'
|
48
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
|
47
49
|
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
48
50
|
spec.add_development_dependency 'strong_versions', '~> 0.4.5'
|
49
51
|
spec.add_development_dependency 'webmock', '~> 3.4'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orchestration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_url
|
@@ -94,20 +94,6 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '6.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: bundler
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '1.16'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.16'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: bunny
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +114,14 @@ dependencies:
|
|
128
114
|
requirements:
|
129
115
|
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.3.
|
117
|
+
version: 0.3.2
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.3.
|
124
|
+
version: 0.3.2
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: mongoid
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,14 +226,56 @@ dependencies:
|
|
240
226
|
requirements:
|
241
227
|
- - "~>"
|
242
228
|
- !ruby/object:Gem::Version
|
243
|
-
version:
|
229
|
+
version: '1.12'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '1.12'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: rubocop-rails
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - "~>"
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '2.9'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - "~>"
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '2.9'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: rubocop-rake
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: 0.5.1
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: 0.5.1
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: rubocop-rspec
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: '2.2'
|
244
272
|
type: :development
|
245
273
|
prerelease: false
|
246
274
|
version_requirements: !ruby/object:Gem::Requirement
|
247
275
|
requirements:
|
248
276
|
- - "~>"
|
249
277
|
- !ruby/object:Gem::Version
|
250
|
-
version:
|
278
|
+
version: '2.2'
|
251
279
|
- !ruby/object:Gem::Dependency
|
252
280
|
name: sqlite3
|
253
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -371,7 +399,7 @@ files:
|
|
371
399
|
homepage: https://github.com/bobf/orchestration
|
372
400
|
licenses: []
|
373
401
|
metadata: {}
|
374
|
-
post_install_message:
|
402
|
+
post_install_message:
|
375
403
|
rdoc_options: []
|
376
404
|
require_paths:
|
377
405
|
- lib
|
@@ -387,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
387
415
|
version: '0'
|
388
416
|
requirements: []
|
389
417
|
rubygems_version: 3.0.3
|
390
|
-
signing_key:
|
418
|
+
signing_key:
|
391
419
|
specification_version: 4
|
392
420
|
summary: Docker orchestration toolkit
|
393
421
|
test_files: []
|