orchestration 0.3.14 → 0.3.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89c669c1e10aec69b7b61b51e683badb050ee64352f67e0a1be7f44efcdd16f4
4
- data.tar.gz: bd6525302ab21aaceec8a07bdb1381e5599b401e120e128880c6ce8476ddeb33
3
+ metadata.gz: ff7499be14d897dc5d5385c55f9879e3e0f4a5d8e26ff2b1900da4bdf89ac8d1
4
+ data.tar.gz: '00181ce547be977794bd8fc168adda7e846402bb8a0d0ee26495efc9f731c892'
5
5
  SHA512:
6
- metadata.gz: 151fd08a7f0f01b5612123a083537e8d410b17fffd0c8ab74640fd91338f6a6a054aeaa6838889c4dbe0b16a3d7e64ad2aa136f45f1bf7e5d94c94f9e95f3a16
7
- data.tar.gz: f31f18aff4138549dd0bd46546ec4b02e168298cc60b99f95b00d1a86193a6ae17c90a361630e2faa1bcbf0bc96d3d71e2ce4a58c86e679eed9f16353cea8374
6
+ metadata.gz: 6d903f4a1ebadb2f58d4ad227257596895213f9a837b35a6eed340ca73a4d731c1e0a3a5665592b070acbec11b2b56bfb342dcec22a4ee59f3cb117391a010b3
7
+ data.tar.gz: 4bf720ae1e9fa003dabe45590b6a7099778327e0c4a62a16e7873407b14a6a822e77a04b127374573592729a833b75fbf73ceb82e9e367854444ff192aae3639
data/README.md CHANGED
@@ -11,7 +11,7 @@ _Orchestration_ is a toolkit for testing, building, and deploying _Ruby_ (includ
11
11
  Add _Orchestration_ to your Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'orchestration', '~> 0.3.14'
14
+ gem 'orchestration', '~> 0.3.15'
15
15
  ```
16
16
 
17
17
  Install:
@@ -11,5 +11,4 @@ require 'orchestration/docker_compose/configuration'
11
11
  require 'orchestration/docker_compose/app_service'
12
12
  require 'orchestration/docker_compose/database_service'
13
13
  require 'orchestration/docker_compose/mongo_service'
14
- require 'orchestration/docker_compose/haproxy_service'
15
14
  require 'orchestration/docker_compose/rabbitmq_service'
@@ -11,7 +11,8 @@ module Orchestration
11
11
  def definition
12
12
  {
13
13
  'image' => '${DOCKER_ORGANIZATION}/${DOCKER_REPOSITORY}',
14
- 'environment' => environment
14
+ 'environment' => environment,
15
+ 'ports' => ports
15
16
  }
16
17
  end
17
18
 
@@ -23,8 +24,7 @@ module Orchestration
23
24
  'RAILS_SERVE_STATIC_FILES' => '1',
24
25
  'UNICORN_PRELOAD_APP' => '1',
25
26
  'UNICORN_TIMEOUT' => '60',
26
- 'UNICORN_WORKER_PROCESSES' => '8',
27
- 'SERVICE_PORTS' => '8080'
27
+ 'UNICORN_WORKER_PROCESSES' => '8'
28
28
  }.merge(inherited_environment)
29
29
  end
30
30
 
@@ -33,10 +33,13 @@ module Orchestration
33
33
  'DATABASE_URL' => nil,
34
34
  'HOST_UID' => nil,
35
35
  'RAILS_ENV' => nil,
36
- 'SECRET_KEY_BASE' => nil,
37
- 'VIRTUAL_HOST' => nil
36
+ 'SECRET_KEY_BASE' => nil
38
37
  }
39
38
  end
39
+
40
+ def ports
41
+ ['${LISTEN_PORT}:8080']
42
+ end
40
43
  end
41
44
  end
42
45
  end
@@ -28,8 +28,7 @@ module Orchestration
28
28
  app: AppService,
29
29
  database: DatabaseService,
30
30
  mongo: MongoService,
31
- rabbitmq: RabbitMQService,
32
- haproxy: HAProxyService
31
+ rabbitmq: RabbitMQService
33
32
  }
34
33
  end
35
34
 
@@ -83,7 +83,7 @@ module Orchestration
83
83
  when :test, :development
84
84
  %i[database mongo rabbitmq]
85
85
  when :production
86
- %i[haproxy app database mongo rabbitmq]
86
+ %i[app database mongo rabbitmq]
87
87
  when :local, nil
88
88
  []
89
89
  else
@@ -102,8 +102,7 @@ module Orchestration
102
102
  app: Orchestration::Services::App::Configuration,
103
103
  database: Orchestration::Services::Database::Configuration,
104
104
  mongo: Orchestration::Services::Mongo::Configuration,
105
- rabbitmq: Orchestration::Services::RabbitMQ::Configuration,
106
- haproxy: Orchestration::Services::HAProxy::Configuration
105
+ rabbitmq: Orchestration::Services::RabbitMQ::Configuration
107
106
  }.fetch(service).new(@env)
108
107
  end
109
108
 
@@ -12,5 +12,4 @@ require 'orchestration/services/app'
12
12
  require 'orchestration/services/database'
13
13
  require 'orchestration/services/listener'
14
14
  require 'orchestration/services/mongo'
15
- require 'orchestration/services/haproxy'
16
15
  require 'orchestration/services/rabbitmq'
@@ -32,13 +32,11 @@ module Orchestration
32
32
  end
33
33
 
34
34
  def local_port
35
- key = @service_name == 'app' ? 'haproxy' : @service_name
36
-
37
- return ENV.fetch('LISTEN_PORT', '3000').to_i if key == 'haproxy'
35
+ return ENV.fetch('LISTEN_PORT', '3000').to_i if @service_name == 'app'
38
36
 
39
37
  @env.docker_compose_config
40
38
  .fetch('services')
41
- .fetch(key)
39
+ .fetch(@service_name)
42
40
  .fetch('ports')
43
41
  .first
44
42
  .partition(':')
@@ -53,16 +53,22 @@ module Orchestration
53
53
  def url_config
54
54
  return nil unless ENV.key?('MONGO_URL')
55
55
 
56
- host, _, port = ENV['MONGO_URL'].partition(':')
57
- { host: host, port: port.empty? ? '27017' : port }
56
+ host, _, port = ENV['MONGO_URL'].rpartition('/').first.partition(':')
57
+ _, _, database = ENV['MONGO_URL'].rpartition('/')
58
+ { host: host, port: port.empty? ? '27017' : port, database: database }
58
59
  end
59
60
 
60
61
  def database
62
+ return url_config[:database] unless url_config.nil?
63
+
61
64
  env_config = config.fetch(@env.environment)
62
65
  return env_config.fetch('database') if env_config.key?('database')
63
66
 
64
67
  bad_config_error if clients_key.nil?
68
+ merged_config(env_config)
69
+ end
65
70
 
71
+ def merged_config(env_config)
66
72
  env_config
67
73
  .fetch(clients_key)
68
74
  .fetch('default')
@@ -14,12 +14,17 @@ module Orchestration
14
14
  return unless defined?(RabbitMQ)
15
15
  return unless File.exist?(@env.rabbitmq_configuration_path)
16
16
 
17
+ if ENV.key?('RABBITMQ_URL')
18
+ @settings = from_url
19
+ return
20
+ end
21
+
17
22
  @settings = config.fetch(@env.environment)
18
23
  @settings.merge!('port' => PORT) unless @settings.key?('port')
19
24
  end
20
25
 
21
26
  def friendly_config
22
- "[bunny] amqp://#{host}:#{local_port}"
27
+ "[bunny] amqp://#{host}:#{port}"
23
28
  end
24
29
 
25
30
  private
@@ -27,6 +32,19 @@ module Orchestration
27
32
  def config
28
33
  yaml(File.read(@env.rabbitmq_configuration_path))
29
34
  end
35
+
36
+ def host
37
+ @settings.fetch('host')
38
+ end
39
+
40
+ def port
41
+ @settings.fetch('port')
42
+ end
43
+
44
+ def from_url
45
+ uri = URI.parse(ENV.fetch('RABBITMQ_URL'))
46
+ { 'host' => uri.host, 'port' => uri.port || 5672 }
47
+ end
30
48
  end
31
49
  end
32
50
  end
@@ -8,10 +8,6 @@ else ifneq (,$(RACK_ENV))
8
8
  endif
9
9
 
10
10
  verify-environment:
11
- ifndef VIRTUAL_HOST
12
- @$(error `VIRTUAL_HOST` must be defined in environment)
13
- endif
14
-
15
11
  ifndef LISTEN_PORT
16
12
  @$(error `LISTEN_PORT` must be defined in environment)
17
13
  endif
@@ -46,6 +46,9 @@ endif
46
46
  start:
47
47
  @echo "Starting containers..."
48
48
  ifeq (${env},$(filter ${env},test development))
49
+ @# If our hostname is also known to Docker as a container ID then join
50
+ @# the same network as our dependencies. This allows us to run side-car
51
+ @# dependencies if we are running in a container (e.g. in Jenkins).
49
52
  @(docker ps --format "{{.ID}}" | grep -q $(shell hostname) && ${compose} up -d && docker network connect ${docker_repository}_${env}_default $(shell hostname)) || ${compose} up -d
50
53
  else
51
54
  @${compose} up -d --scale app=$${instances:-1}
@@ -55,6 +58,7 @@ endif
55
58
  .PHONY: stop
56
59
  stop:
57
60
  @echo "Stopping containers..."
61
+ @(docker ps --format "{{.ID}}" | grep -q $(shell hostname) && docker network disconnect ${docker_repository}_${env}_default $(shell hostname))
58
62
  @${compose} down
59
63
  @echo "All containers stopped."
60
64
 
@@ -165,20 +169,6 @@ ifeq (${env},$(filter ${env},test development))
165
169
  @${rake} orchestration:rabbitmq:wait
166
170
  endif
167
171
 
168
- ## Production wait commands
169
-
170
- .PHONY: wait-haproxy
171
- wait-haproxy:
172
- ifneq (${env},$(filter ${env},test development))
173
- @${rake} orchestration:haproxy:wait LISTEN_PORT=${LISTEN_PORT}
174
- endif
175
-
176
- .PHONY: wait-app
177
- wait-app:
178
- ifneq (${env},$(filter ${env},test development))
179
- @${rake} orchestration:app:wait LISTEN_PORT=${LISTEN_PORT}
180
- endif
181
-
182
172
  ### Docker build commands ###
183
173
 
184
174
  .PHONY: build
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.3.14'
4
+ VERSION = '0.3.15'
5
5
  end
@@ -29,13 +29,6 @@ namespace :orchestration do
29
29
  end
30
30
  end
31
31
 
32
- namespace :haproxy do
33
- desc I18n.t('orchestration.rake.haproxy.wait')
34
- task :wait do
35
- Orchestration::Services::HAProxy::Healthcheck.start
36
- end
37
- end
38
-
39
32
  namespace :rabbitmq do
40
33
  desc I18n.t('orchestration.rake.rabbitmq.wait')
41
34
  task :wait do
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.3.14
4
+ version: 0.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-31 00:00:00.000000000 Z
11
+ date: 2019-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -337,7 +337,6 @@ files:
337
337
  - lib/orchestration/docker_compose/app_service.rb
338
338
  - lib/orchestration/docker_compose/configuration.rb
339
339
  - lib/orchestration/docker_compose/database_service.rb
340
- - lib/orchestration/docker_compose/haproxy_service.rb
341
340
  - lib/orchestration/docker_compose/install_generator.rb
342
341
  - lib/orchestration/docker_compose/mongo_service.rb
343
342
  - lib/orchestration/docker_compose/rabbitmq_service.rb
@@ -359,9 +358,6 @@ files:
359
358
  - lib/orchestration/services/database/adapters/sqlite3.rb
360
359
  - lib/orchestration/services/database/configuration.rb
361
360
  - lib/orchestration/services/database/healthcheck.rb
362
- - lib/orchestration/services/haproxy.rb
363
- - lib/orchestration/services/haproxy/configuration.rb
364
- - lib/orchestration/services/haproxy/healthcheck.rb
365
361
  - lib/orchestration/services/healthcheck_base.rb
366
362
  - lib/orchestration/services/listener.rb
367
363
  - lib/orchestration/services/listener/configuration.rb
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Orchestration
4
- module DockerCompose
5
- class HAProxyService
6
- def initialize(config, environment)
7
- @environment = environment
8
- @config = config
9
- end
10
-
11
- def definition
12
- {
13
- 'deploy' => {
14
- 'placement' => { 'constraints' => ['node.role == manager'] }
15
- },
16
- 'image' => 'dockercloud/haproxy',
17
- 'ports' => %w[${LISTEN_PORT}:80],
18
- 'volumes' => [
19
- '/var/run/docker.sock:/var/run/docker.sock:ro'
20
- ]
21
- }
22
- end
23
- end
24
- end
25
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Orchestration
4
- module Services
5
- module HAProxy
6
- end
7
- end
8
- end
9
-
10
- require 'orchestration/services/haproxy/configuration'
11
- require 'orchestration/services/haproxy/healthcheck'
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Orchestration
4
- module Services
5
- module HAProxy
6
- class Configuration
7
- include ConfigurationBase
8
-
9
- self.service_name = 'haproxy'
10
-
11
- def initialize(env, service_name = nil)
12
- super
13
- @settings = {}
14
- end
15
-
16
- def friendly_config
17
- "[haproxy] #{host}:#{local_port}"
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Orchestration
4
- module Services
5
- module HAProxy
6
- class Healthcheck
7
- include HealthcheckBase
8
-
9
- def connect
10
- Net::HTTP.start('localhost', @configuration.local_port)
11
- end
12
-
13
- def connection_errors
14
- [Errno::ECONNREFUSED]
15
- end
16
- end
17
- end
18
- end
19
- end