orchestration 0.6.7 → 0.7.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cb2b72a148e2687680311cd050b426ccd06c063e4ab01e0affc03be0afbc16d
4
- data.tar.gz: 97210bd8c3133b7d246ed4b8cd92f56c148a91c283b3ad51f8c4d61e8d6ed690
3
+ metadata.gz: 3423dc31e2b526868cb869c930d6f73039437939aa7b2ceb859e0e8106536344
4
+ data.tar.gz: 4669fd75876e047f52d256dd2f2e3840ecd42f157b04c6f4f81e315ae96ca6ff
5
5
  SHA512:
6
- metadata.gz: 751f8433ec5094ee87639115d4c0f43e14ed0d7f2c5382fd8d79dd050d9ae27073f962304776d83d74e2b57bb97ae3e2bf774fff9a967a0b534e950462914689
7
- data.tar.gz: 19b986c4ec255c2f451d99616d310235e10abcf8c403f87ef02bd1b5551da4189fdf7bf72be47f07499ed12142193b7d16e3c67b803f6c0951c6227d02d9b380
6
+ metadata.gz: 2a4f0579b2698d30103975b175b8a4cdc1df51c5ce883560f2b11f24b8fd3307fd1e6a35868689f6152d182e07ddbc65b6f081fe4b33ae1114e7957b64338c02
7
+ data.tar.gz: 380413ccb1b108614ad09247a2435178a042c352775712b287c79e707938aa409290ab42f9b0b5d7cc32184fe73de200a8a551ae5c24ba37b3c08655e4caeaf0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.9
1
+ 3.1.2
data/.strong_versions.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  ignore:
2
2
  - i18n
3
3
  - rails
4
+ - activerecord
data/Gemfile.lock CHANGED
@@ -1,76 +1,82 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orchestration (0.6.7)
4
+ orchestration (0.7.2)
5
5
  database_url (~> 0.1.2)
6
6
  erubis (~> 2.7)
7
- i18n (>= 0.5)
8
- paint (~> 2.0)
9
- rails (>= 4.1)
10
- thor (~> 1.0)
7
+ i18n
8
+ paint (~> 2.2)
9
+ rails (>= 6.1)
10
+ thor (~> 1.2)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- actioncable (6.1.4.7)
16
- actionpack (= 6.1.4.7)
17
- activesupport (= 6.1.4.7)
15
+ actioncable (7.0.3)
16
+ actionpack (= 7.0.3)
17
+ activesupport (= 7.0.3)
18
18
  nio4r (~> 2.0)
19
19
  websocket-driver (>= 0.6.1)
20
- actionmailbox (6.1.4.7)
21
- actionpack (= 6.1.4.7)
22
- activejob (= 6.1.4.7)
23
- activerecord (= 6.1.4.7)
24
- activestorage (= 6.1.4.7)
25
- activesupport (= 6.1.4.7)
20
+ actionmailbox (7.0.3)
21
+ actionpack (= 7.0.3)
22
+ activejob (= 7.0.3)
23
+ activerecord (= 7.0.3)
24
+ activestorage (= 7.0.3)
25
+ activesupport (= 7.0.3)
26
26
  mail (>= 2.7.1)
27
- actionmailer (6.1.4.7)
28
- actionpack (= 6.1.4.7)
29
- actionview (= 6.1.4.7)
30
- activejob (= 6.1.4.7)
31
- activesupport (= 6.1.4.7)
27
+ net-imap
28
+ net-pop
29
+ net-smtp
30
+ actionmailer (7.0.3)
31
+ actionpack (= 7.0.3)
32
+ actionview (= 7.0.3)
33
+ activejob (= 7.0.3)
34
+ activesupport (= 7.0.3)
32
35
  mail (~> 2.5, >= 2.5.4)
36
+ net-imap
37
+ net-pop
38
+ net-smtp
33
39
  rails-dom-testing (~> 2.0)
34
- actionpack (6.1.4.7)
35
- actionview (= 6.1.4.7)
36
- activesupport (= 6.1.4.7)
37
- rack (~> 2.0, >= 2.0.9)
40
+ actionpack (7.0.3)
41
+ actionview (= 7.0.3)
42
+ activesupport (= 7.0.3)
43
+ rack (~> 2.0, >= 2.2.0)
38
44
  rack-test (>= 0.6.3)
39
45
  rails-dom-testing (~> 2.0)
40
46
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
- actiontext (6.1.4.7)
42
- actionpack (= 6.1.4.7)
43
- activerecord (= 6.1.4.7)
44
- activestorage (= 6.1.4.7)
45
- activesupport (= 6.1.4.7)
47
+ actiontext (7.0.3)
48
+ actionpack (= 7.0.3)
49
+ activerecord (= 7.0.3)
50
+ activestorage (= 7.0.3)
51
+ activesupport (= 7.0.3)
52
+ globalid (>= 0.6.0)
46
53
  nokogiri (>= 1.8.5)
47
- actionview (6.1.4.7)
48
- activesupport (= 6.1.4.7)
54
+ actionview (7.0.3)
55
+ activesupport (= 7.0.3)
49
56
  builder (~> 3.1)
50
57
  erubi (~> 1.4)
51
58
  rails-dom-testing (~> 2.0)
52
59
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
53
- activejob (6.1.4.7)
54
- activesupport (= 6.1.4.7)
60
+ activejob (7.0.3)
61
+ activesupport (= 7.0.3)
55
62
  globalid (>= 0.3.6)
56
- activemodel (6.1.4.7)
57
- activesupport (= 6.1.4.7)
58
- activerecord (6.1.4.7)
59
- activemodel (= 6.1.4.7)
60
- activesupport (= 6.1.4.7)
61
- activestorage (6.1.4.7)
62
- actionpack (= 6.1.4.7)
63
- activejob (= 6.1.4.7)
64
- activerecord (= 6.1.4.7)
65
- activesupport (= 6.1.4.7)
66
- marcel (~> 1.0.0)
63
+ activemodel (7.0.3)
64
+ activesupport (= 7.0.3)
65
+ activerecord (7.0.3)
66
+ activemodel (= 7.0.3)
67
+ activesupport (= 7.0.3)
68
+ activestorage (7.0.3)
69
+ actionpack (= 7.0.3)
70
+ activejob (= 7.0.3)
71
+ activerecord (= 7.0.3)
72
+ activesupport (= 7.0.3)
73
+ marcel (~> 1.0)
67
74
  mini_mime (>= 1.1.0)
68
- activesupport (6.1.4.7)
75
+ activesupport (7.0.3)
69
76
  concurrent-ruby (~> 1.0, >= 1.0.2)
70
77
  i18n (>= 1.6, < 2)
71
78
  minitest (>= 5.1)
72
79
  tzinfo (~> 2.0)
73
- zeitwerk (~> 2.3)
74
80
  addressable (2.8.0)
75
81
  public_suffix (>= 2.0.2, < 5.0)
76
82
  amq-protocol (2.3.2)
@@ -85,8 +91,9 @@ GEM
85
91
  rexml
86
92
  crass (1.0.6)
87
93
  database_url (0.1.2)
88
- devpack (0.3.3)
94
+ devpack (0.4.0)
89
95
  diff-lcs (1.5.0)
96
+ digest (3.1.0)
90
97
  erubi (1.10.0)
91
98
  erubis (2.7.0)
92
99
  globalid (1.0.0)
@@ -110,6 +117,20 @@ GEM
110
117
  mongo (>= 2.10.5, < 3.0.0)
111
118
  ruby2_keywords (~> 0.0.5)
112
119
  mysql2 (0.5.4)
120
+ net-imap (0.2.3)
121
+ digest
122
+ net-protocol
123
+ strscan
124
+ net-pop (0.1.1)
125
+ digest
126
+ net-protocol
127
+ timeout
128
+ net-protocol (0.1.3)
129
+ timeout
130
+ net-smtp (0.3.1)
131
+ digest
132
+ net-protocol
133
+ timeout
113
134
  nio4r (2.5.8)
114
135
  nokogiri (1.13.6-x86_64-linux)
115
136
  racc (~> 1.4)
@@ -123,35 +144,36 @@ GEM
123
144
  rack (2.2.3)
124
145
  rack-test (1.1.0)
125
146
  rack (>= 1.0, < 3)
126
- rails (6.1.4.7)
127
- actioncable (= 6.1.4.7)
128
- actionmailbox (= 6.1.4.7)
129
- actionmailer (= 6.1.4.7)
130
- actionpack (= 6.1.4.7)
131
- actiontext (= 6.1.4.7)
132
- actionview (= 6.1.4.7)
133
- activejob (= 6.1.4.7)
134
- activemodel (= 6.1.4.7)
135
- activerecord (= 6.1.4.7)
136
- activestorage (= 6.1.4.7)
137
- activesupport (= 6.1.4.7)
147
+ rails (7.0.3)
148
+ actioncable (= 7.0.3)
149
+ actionmailbox (= 7.0.3)
150
+ actionmailer (= 7.0.3)
151
+ actionpack (= 7.0.3)
152
+ actiontext (= 7.0.3)
153
+ actionview (= 7.0.3)
154
+ activejob (= 7.0.3)
155
+ activemodel (= 7.0.3)
156
+ activerecord (= 7.0.3)
157
+ activestorage (= 7.0.3)
158
+ activesupport (= 7.0.3)
138
159
  bundler (>= 1.15.0)
139
- railties (= 6.1.4.7)
140
- sprockets-rails (>= 2.0.0)
160
+ railties (= 7.0.3)
141
161
  rails-dom-testing (2.0.3)
142
162
  activesupport (>= 4.2.0)
143
163
  nokogiri (>= 1.6)
144
164
  rails-html-sanitizer (1.4.2)
145
165
  loofah (~> 2.3)
146
- railties (6.1.4.7)
147
- actionpack (= 6.1.4.7)
148
- activesupport (= 6.1.4.7)
166
+ railties (7.0.3)
167
+ actionpack (= 7.0.3)
168
+ activesupport (= 7.0.3)
149
169
  method_source
150
- rake (>= 0.13)
170
+ rake (>= 12.2)
151
171
  thor (~> 1.0)
172
+ zeitwerk (~> 2.5)
152
173
  rainbow (3.1.1)
153
- rake (10.5.0)
174
+ rake (13.0.6)
154
175
  rbtree (0.4.5)
176
+ redis (4.6.0)
155
177
  regexp_parser (2.4.0)
156
178
  rexml (3.2.5)
157
179
  rspec (3.11.0)
@@ -185,8 +207,8 @@ GEM
185
207
  activesupport (>= 4.2.0)
186
208
  rack (>= 1.1)
187
209
  rubocop (>= 1.7.0, < 2.0)
188
- rubocop-rake (0.5.1)
189
- rubocop
210
+ rubocop-rake (0.6.0)
211
+ rubocop (~> 1.0)
190
212
  rubocop-rspec (2.11.1)
191
213
  rubocop (~> 1.19)
192
214
  ruby-progressbar (1.11.0)
@@ -195,18 +217,13 @@ GEM
195
217
  sorted_set (1.0.3)
196
218
  rbtree
197
219
  set (~> 1.0)
198
- sprockets (4.0.3)
199
- concurrent-ruby (~> 1.0)
200
- rack (> 1, < 3)
201
- sprockets-rails (3.4.2)
202
- actionpack (>= 5.2)
203
- activesupport (>= 5.2)
204
- sprockets (>= 3.0.0)
205
220
  sqlite3 (1.4.2)
206
221
  strong_versions (0.4.5)
207
222
  i18n (>= 0.5)
208
223
  paint (~> 2.0)
224
+ strscan (3.0.3)
209
225
  thor (1.2.1)
226
+ timeout (0.3.0)
210
227
  tzinfo (2.0.4)
211
228
  concurrent-ruby (~> 1.0)
212
229
  unicode-display_width (2.1.0)
@@ -223,24 +240,25 @@ PLATFORMS
223
240
  x86_64-linux
224
241
 
225
242
  DEPENDENCIES
226
- activerecord (~> 6.0)
227
- bunny (~> 2.12)
228
- devpack (~> 0.3.2)
229
- mongoid (~> 7.0)
230
- mysql2 (~> 0.5.2)
243
+ activerecord (>= 6.0)
244
+ bunny (~> 2.19)
245
+ devpack (~> 0.4.0)
246
+ mongoid (~> 7.4)
247
+ mysql2 (~> 0.5.3)
231
248
  orchestration!
232
- pg (~> 1.1)
233
- rails (~> 6.0)
234
- rake (~> 10.0)
235
- rspec (~> 3.0)
236
- rspec-its (~> 1.2)
237
- rubocop (~> 1.12)
238
- rubocop-rails (~> 2.9)
239
- rubocop-rake (~> 0.5.1)
240
- rubocop-rspec (~> 2.2)
241
- sqlite3 (~> 1.3)
249
+ pg (~> 1.3)
250
+ rails
251
+ rake (~> 13.0)
252
+ redis (~> 4.6)
253
+ rspec (~> 3.11)
254
+ rspec-its (~> 1.3)
255
+ rubocop (~> 1.28)
256
+ rubocop-rails (~> 2.14)
257
+ rubocop-rake (~> 0.6.0)
258
+ rubocop-rspec (~> 2.10)
259
+ sqlite3 (~> 1.4)
242
260
  strong_versions (~> 0.4.5)
243
- webmock (~> 3.4)
261
+ webmock (~> 3.14)
244
262
 
245
263
  BUNDLED WITH
246
- 2.3.11
264
+ 2.3.14
data/README.md CHANGED
@@ -26,7 +26,15 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
26
26
 
27
27
  ### Install
28
28
 
29
- Add _Orchestration_ to your Gemfile:
29
+ Add _Orchestration_ to your `Gemfile`:
30
+
31
+ _Ruby 3.x_:
32
+
33
+ ```ruby
34
+ gem 'orchestration', '~> 0.7.2'
35
+ ```
36
+
37
+ _Ruby 2.x_:
30
38
 
31
39
  ```ruby
32
40
  gem 'orchestration', '~> 0.6.7'
@@ -50,11 +58,6 @@ rake orchestration:install server=unicorn # (or 'puma' [default], etc.)
50
58
 
51
59
  To rebuild all build-out at any time, pass `force=yes` to the above install command.
52
60
 
53
- To rebuild just `orchestration/Makefile` (useful after upgrading the _Orchestration_ gem):
54
- ```bash
55
- rake orchestration:install:makefile
56
- ```
57
-
58
61
  You will be prompted to enter values for your _Docker_ organisation and repository name. For example, the _organisation_ and _repository_ for https://hub.docker.com/r/rubyorchestration/sampleapp are `rubyorchestration` and `sampleapp` respectively. If you are unsure of these values, they can be modified later by editing `.orchestration.yml` in the root of your project directory.
59
62
 
60
63
  #### Configuration files
@@ -64,6 +67,7 @@ _Orchestration_ generates the following files where appropriate. Backups are cre
64
67
  * `config/database.yml`
65
68
  * `config/mongoid.yml`
66
69
  * `config/rabbitmq.yml` (see [RabbitMQ Configuration](#rabbitmq-configuration) for more details)
70
+ * `config/redis.yml` (see [Redis Configuration](#redis-configuration) for more details)
67
71
  * `config/unicorn.rb`
68
72
  * `config/puma.rb`
69
73
 
@@ -393,13 +397,6 @@ make stop RAILS_ENV=test
393
397
  <a name="rabbitmq-configuration"></a>
394
398
  ## RabbitMQ Configuration
395
399
 
396
- The [Bunny](https://github.com/ruby-amqp/bunny) _RabbitMQ_ gem does not recognise `config/rabbitmq.yml` or `RABBITMQ_URL`. If your application uses _RabbitMQ_ then you must manually update your code to reference this file, e.g.:
397
-
398
- ```ruby
399
- connection = Bunny.new(config_for(:rabbit_mq)['url'])
400
- connection.start
401
- ```
402
-
403
400
  _Orchestration_ generates the following `config/rabbitmq.yml`:
404
401
 
405
402
  ```
@@ -416,10 +413,42 @@ production:
416
413
  management_url: <%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
417
414
  ```
418
415
 
416
+ The [Bunny](https://github.com/ruby-amqp/bunny) _RabbitMQ_ gem does not recognise `config/rabbitmq.yml` or `RABBITMQ_URL`. If your application uses _RabbitMQ_ then you must manually update your code to reference this file, e.g.:
417
+
418
+ ```ruby
419
+ connection = Bunny.new(Rails.application.config_for(:rabbit_mq)['url'])
420
+ connection.start
421
+ ```
422
+
419
423
  Using this approach, the environment variable `RABBITMQ_URL` can be used to configure _Bunny_ in production (similar to `DATABASE_URL` and `MONGO_URL`).
420
424
 
421
425
  This is a convention of the _Orchestration_ gem intended to make _RabbitMQ_ configuration consistent with other services.
422
426
 
427
+ <a name="redis-configuration"></a>
428
+ ## Redis Configuration
429
+
430
+ _Orchestration_ generates the following `config/redis.yml`:
431
+
432
+ ```
433
+ development:
434
+ url: redis://127.0.0.1:51071
435
+
436
+ test:
437
+ url: redis://127.0.0.1:51069
438
+ ```
439
+
440
+ The [Redis](https://github.com/redis/redis-rb) gem does not recognise `config/redis.yml`. If your application uses _Redis_ then you must manually update your code to reference this file, e.g.:
441
+
442
+ ```ruby
443
+ # config/initializers/redis.rb
444
+
445
+ ENV['REDIS_URL'] ||= Rails.application.config_for(:redis)['url']
446
+ ```
447
+ _Redis_ will then use `REDIS_URL` for all connections.
448
+
449
+ This allows `development` and `test` environments to auto-load the correct config for the relevant containers while also allowing `production` to use either the auto-generated _Redis_ service or an external _Redis_ instance.
450
+
451
+
423
452
  ## Alternate Database Configuration Files
424
453
 
425
454
  If you have multiple databases configured in various `config/database.*.yml` files then the `make wait` command will automatically detect database configurations.
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Orchestration
4
4
  module DockerCompose
5
+ # rubocop:disable Metrics/ClassLength
5
6
  class AppService
6
7
  include ComposeHelpers
7
8
 
@@ -54,7 +55,7 @@ module Orchestration
54
55
  raise ArgumentError,
55
56
  I18n.t(
56
57
  'orchestration.rake.app.unspported_web_server',
57
- server: server,
58
+ server:,
58
59
  expected: %w[puma unicorn]
59
60
  )
60
61
  end
@@ -99,13 +100,19 @@ module Orchestration
99
100
  'WEB_HEALTHCHECK_PATH' => '/healthcheck',
100
101
  'WEB_PORT' => 8080,
101
102
  'DATABASE_URL' => database_url
102
- }.merge(inherited_environment.to_h { |key| [key, nil] }).merge(rabbitmq_urls)
103
+ }.merge(inherited_environment.to_h { |key| [key, nil] }).merge(rabbitmq_urls).merge(redis_url)
103
104
  end
104
105
 
105
106
  def rabbitmq_urls
106
107
  return {} unless Services::RabbitMQ::Configuration.new(Environment.new).enabled?
107
108
 
108
- { 'RABBITMQ_URL' => 'amqp://rabbitmq:5672', 'RABBITMQ_MANAGEMENT_URL' => 'http://rabbitmq:15672' }
109
+ { 'RABBITMQ_URL' => 'amqp://rabbitmq-local:5672', 'RABBITMQ_MANAGEMENT_URL' => 'http://rabbitmq-local:15672' }
110
+ end
111
+
112
+ def redis_url
113
+ return {} unless Services::Redis::Configuration.new(Environment.new).enabled?
114
+
115
+ { 'REDIS_URL' => "redis://redis-local:#{Services::Redis::PORT}" }
109
116
  end
110
117
 
111
118
  def database_url
@@ -124,5 +131,6 @@ module Orchestration
124
131
  ['${PUBLISH_PORT:?PUBLISH_PORT must be provided}:8080']
125
132
  end
126
133
  end
134
+ # rubocop:enable Metrics/ClassLength
127
135
  end
128
136
  end
@@ -39,7 +39,7 @@ module Orchestration
39
39
  return nil unless listener?(name)
40
40
  return ports(name).first[:local].to_i if remote_port.nil?
41
41
 
42
- ports(name).find { |mapping| mapping[:remote] == remote_port }
42
+ ports(name).find { |mapping| mapping[:remote].to_i == remote_port.to_i }
43
43
  .fetch(:local)
44
44
  .to_i
45
45
  rescue NoMethodError
@@ -77,7 +77,7 @@ module Orchestration
77
77
  # '{sidecar-27018:}27017' => '27018:27017'
78
78
  local, _, remote = mapping.sub(/\${sidecar-(\d+):}/, '\1:')
79
79
  .partition(':')
80
- { local: local, remote: remote }
80
+ { local:, remote: }
81
81
  end
82
82
  end
83
83
  end
@@ -32,7 +32,8 @@ module Orchestration
32
32
  app: AppService,
33
33
  database: DatabaseService,
34
34
  mongo: MongoService,
35
- rabbitmq: RabbitMQService
35
+ rabbitmq: RabbitMQService,
36
+ redis: RedisService
36
37
  }
37
38
  end
38
39
 
@@ -67,9 +67,9 @@ module Orchestration
67
67
  def service_names(environment)
68
68
  case environment
69
69
  when :test, :development
70
- %i[database mongo rabbitmq]
70
+ %i[database mongo rabbitmq redis]
71
71
  when :deployment
72
- %i[app database mongo rabbitmq]
72
+ %i[app database mongo rabbitmq redis]
73
73
  when :local, nil
74
74
  []
75
75
  else
@@ -88,7 +88,8 @@ module Orchestration
88
88
  app: Orchestration::Services::App::Configuration,
89
89
  database: Orchestration::Services::Database::Configuration,
90
90
  mongo: Orchestration::Services::Mongo::Configuration,
91
- rabbitmq: Orchestration::Services::RabbitMQ::Configuration
91
+ rabbitmq: Orchestration::Services::RabbitMQ::Configuration,
92
+ redis: Orchestration::Services::Redis::Configuration
92
93
  }.fetch(service).new(@env)
93
94
  end
94
95
 
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orchestration
4
+ module DockerCompose
5
+ class RedisService
6
+ include ComposeHelpers
7
+
8
+ def initialize(config, environment)
9
+ @config = config
10
+ @environment = environment
11
+ end
12
+
13
+ def definition
14
+ return nil unless @config.enabled?
15
+
16
+ { 'image' => 'library/redis:7.0', 'networks' => networks }.merge(ports)
17
+ end
18
+
19
+ def ports
20
+ return {} unless %i[development test].include?(@environment)
21
+
22
+ container_port = Orchestration::Services::Redis::PORT
23
+
24
+ { 'ports' => ["#{sidecar_port(@environment)}#{container_port}"] }
25
+ end
26
+ end
27
+ end
28
+ end
@@ -14,3 +14,4 @@ require 'orchestration/docker_compose/app_service'
14
14
  require 'orchestration/docker_compose/database_service'
15
15
  require 'orchestration/docker_compose/mongo_service'
16
16
  require 'orchestration/docker_compose/rabbitmq_service'
17
+ require 'orchestration/docker_compose/redis_service'
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
+ # rubocop:disable Metrics/ClassLength
4
5
  class Environment
5
6
  def initialize(options = {})
6
7
  @environment = options.fetch(:environment, nil)
@@ -9,7 +10,7 @@ module Orchestration
9
10
  def environment
10
11
  return @environment unless @environment.nil?
11
12
 
12
- ENV.fetch('RAILS_ENV') { ENV.fetch('RACK_ENV', 'development') }
13
+ ENV.fetch('RAILS_ENV', nil) || ENV.fetch('RACK_ENV', nil) || 'development'
13
14
  end
14
15
 
15
16
  def web_server
@@ -20,9 +21,9 @@ module Orchestration
20
21
  def database_url
21
22
  case environment
22
23
  when 'development'
23
- ENV.fetch('DEVELOPMENT_DATABASE_URL') { ENV.fetch('DATABASE_URL', nil) }
24
+ ENV.fetch('DEVELOPMENT_DATABASE_URL', nil) || ENV.fetch('DATABASE_URL', nil)
24
25
  when 'test'
25
- ENV.fetch('TEST_DATABASE_URL') { ENV.fetch('DATABASE_URL', nil) }
26
+ ENV.fetch('TEST_DATABASE_URL', nil) || ENV.fetch('DATABASE_URL', nil)
26
27
  else
27
28
  ENV.fetch('DATABASE_URL', nil)
28
29
  end
@@ -44,6 +45,10 @@ module Orchestration
44
45
  root.join('config', 'rabbitmq.yml')
45
46
  end
46
47
 
48
+ def redis_configuration_path
49
+ root.join('config', 'redis.yml')
50
+ end
51
+
47
52
  def orchestration_configuration_path
48
53
  root.join('.orchestration.yml')
49
54
  end
@@ -136,4 +141,5 @@ module Orchestration
136
141
  end.join
137
142
  end
138
143
  end
144
+ # rubocop:enable Metrics/ClassLength
139
145
  end
@@ -95,9 +95,9 @@ module Orchestration
95
95
  end
96
96
 
97
97
  def ensure_line_in_file(path, line, echo: true, regex: nil)
98
- return if line_in_file?(path, line: line, regex: regex)
98
+ return if line_in_file?(path, line:, regex:)
99
99
 
100
- append_file(path, "\n#{line.chomp}\n", echo: echo)
100
+ append_file(path, "\n#{line.chomp}\n", echo:)
101
101
  true
102
102
  end
103
103
 
@@ -131,7 +131,7 @@ module Orchestration
131
131
 
132
132
  def force?
133
133
  # Rake task was invoked with `force=yes`
134
- ENV['force'] == 'yes'
134
+ ENV.fetch('force', nil) == 'yes'
135
135
  end
136
136
  end
137
137
  end
@@ -68,11 +68,11 @@ module Orchestration
68
68
  path = @env.root.join('config', 'unicorn.rb')
69
69
  create_file(path, content, backup: true)
70
70
  regex = /gem\s+['"]unicorn['"]/
71
- ensure_line_in_file(gemfile_path, "gem 'unicorn'", regex: regex)
71
+ ensure_line_in_file(gemfile_path, "gem 'unicorn'", regex:)
72
72
  end
73
73
 
74
74
  def database_yml
75
- return unless defined?(ActiveRecord)
75
+ return unless defined?(::ActiveRecord)
76
76
 
77
77
  adapter = DockerCompose::ComposeConfiguration.database_adapter_name
78
78
  return if adapter == 'sqlite3'
@@ -81,17 +81,23 @@ module Orchestration
81
81
  end
82
82
 
83
83
  def mongoid_yml
84
- return unless defined?(Mongoid)
84
+ return unless defined?(::Mongoid)
85
85
 
86
86
  service_config('mongoid.yml', Services::Mongo::Configuration)
87
87
  end
88
88
 
89
89
  def rabbitmq_yml
90
- return unless defined?(Bunny)
90
+ return unless defined?(::Bunny)
91
91
 
92
92
  service_config('rabbitmq.yml', Services::RabbitMQ::Configuration)
93
93
  end
94
94
 
95
+ def redis_yml
96
+ return unless defined?(::Redis)
97
+
98
+ service_config('redis.yml', Services::Redis::Configuration)
99
+ end
100
+
95
101
  def env
96
102
  simple_copy('env', @env.root.join('.env'), overwrite: false)
97
103
  end
@@ -316,16 +316,16 @@ setup: _log-notify
316
316
  @$(call make,start env=${env})
317
317
  ifneq (,$(wildcard config/database.yml))
318
318
  @$(call echo,Preparing ${env_human} database)
319
- @$(call system,rake db:create RAILS_ENV="${env}")
319
+ @$(call system,rake db:create RAILS_ENV="${env}" DATABASE_URL='${url}')
320
320
  @${rake} db:create RAILS_ENV=${env} DATABASE_URL='${url}' ${log} || : ${log}
321
321
  ifneq (,$(wildcard db/structure.sql))
322
- @$(call system,rake db:structure:load RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
322
+ @$(call system,rake db:structure:load RAILS_ENV="${env}" DATABASE_URL="${url}")
323
323
  @${rake} db:structure:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
324
324
  else ifneq (,$(wildcard db/schema.rb))
325
- @$(call system,rake db:schema:load RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
325
+ @$(call system,rake db:schema:load RAILS_ENV="${env}" DATABASE_URL="${url}")
326
326
  @${rake} db:schema:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
327
327
  endif
328
- @$(call system,rake db:migrate RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
328
+ @$(call system,rake db:migrate RAILS_ENV="${env}" DATABASE_URL="${url}")
329
329
  @${rake} db:migrate RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
330
330
  endif
331
331
  @if $(MAKE) -n post-setup >/dev/null 2>&1; then \