orchestration 0.7.0 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -4
- data/.ruby-version +1 -0
- data/Gemfile.lock +264 -0
- data/README.md +35 -9
- data/lib/orchestration/docker_compose/app_service.rb +10 -2
- data/lib/orchestration/docker_compose/compose_configuration.rb +1 -1
- data/lib/orchestration/docker_compose/configuration.rb +2 -1
- data/lib/orchestration/docker_compose/install_generator.rb +4 -3
- data/lib/orchestration/docker_compose/redis_service.rb +28 -0
- data/lib/orchestration/docker_compose.rb +1 -0
- data/lib/orchestration/environment.rb +6 -0
- data/lib/orchestration/install_generator.rb +9 -3
- data/lib/orchestration/make/orchestration.mk +15 -6
- data/lib/orchestration/services/redis/configuration.rb +38 -0
- data/lib/orchestration/services/redis/healthcheck.rb +27 -0
- data/lib/orchestration/services/redis.rb +12 -0
- data/lib/orchestration/services.rb +1 -0
- data/lib/orchestration/templates/puma.rb.erb +4 -4
- data/lib/orchestration/templates/rabbitmq.yml.erb +1 -1
- data/lib/orchestration/templates/redis.yml.erb +9 -0
- data/lib/orchestration/version.rb +1 -1
- data/lib/tasks/orchestration.rake +3 -0
- data/orchestration.gemspec +1 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd668d1ea77820075d2ad454dde1691304daed2c1e26d7e446e2e729a62625db
|
4
|
+
data.tar.gz: 0d3e1d8796810142973303a530972b9bb38e165822c7b403c52ddfb439d91947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d308e88beaaf4c792c2aea6c7ac3ea78c5249ac956da2f1a8ae0637432321a1118a02d9ccef59ae6abf51ac0f381e4bf7e7be249721d1bd2138a51e4fda63f4a
|
7
|
+
data.tar.gz: 322620f4c68eb845f63006531355d93193df31757dae2ca97b6bc5d45186262557da6a4f9381fd8dfa6754e619cb370d0b5d93aa6e155f053fb3265e2639ab06
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.2
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
orchestration (0.7.2)
|
5
|
+
database_url (~> 0.1.2)
|
6
|
+
erubis (~> 2.7)
|
7
|
+
i18n
|
8
|
+
paint (~> 2.2)
|
9
|
+
rails (>= 6.1)
|
10
|
+
thor (~> 1.2)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
actioncable (7.0.3)
|
16
|
+
actionpack (= 7.0.3)
|
17
|
+
activesupport (= 7.0.3)
|
18
|
+
nio4r (~> 2.0)
|
19
|
+
websocket-driver (>= 0.6.1)
|
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
|
+
mail (>= 2.7.1)
|
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)
|
35
|
+
mail (~> 2.5, >= 2.5.4)
|
36
|
+
net-imap
|
37
|
+
net-pop
|
38
|
+
net-smtp
|
39
|
+
rails-dom-testing (~> 2.0)
|
40
|
+
actionpack (7.0.3)
|
41
|
+
actionview (= 7.0.3)
|
42
|
+
activesupport (= 7.0.3)
|
43
|
+
rack (~> 2.0, >= 2.2.0)
|
44
|
+
rack-test (>= 0.6.3)
|
45
|
+
rails-dom-testing (~> 2.0)
|
46
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
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)
|
53
|
+
nokogiri (>= 1.8.5)
|
54
|
+
actionview (7.0.3)
|
55
|
+
activesupport (= 7.0.3)
|
56
|
+
builder (~> 3.1)
|
57
|
+
erubi (~> 1.4)
|
58
|
+
rails-dom-testing (~> 2.0)
|
59
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
60
|
+
activejob (7.0.3)
|
61
|
+
activesupport (= 7.0.3)
|
62
|
+
globalid (>= 0.3.6)
|
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)
|
74
|
+
mini_mime (>= 1.1.0)
|
75
|
+
activesupport (7.0.3)
|
76
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
77
|
+
i18n (>= 1.6, < 2)
|
78
|
+
minitest (>= 5.1)
|
79
|
+
tzinfo (~> 2.0)
|
80
|
+
addressable (2.8.0)
|
81
|
+
public_suffix (>= 2.0.2, < 5.0)
|
82
|
+
amq-protocol (2.3.2)
|
83
|
+
ast (2.4.2)
|
84
|
+
bson (4.15.0)
|
85
|
+
builder (3.2.4)
|
86
|
+
bunny (2.19.0)
|
87
|
+
amq-protocol (~> 2.3, >= 2.3.1)
|
88
|
+
sorted_set (~> 1, >= 1.0.2)
|
89
|
+
concurrent-ruby (1.1.10)
|
90
|
+
crack (0.4.5)
|
91
|
+
rexml
|
92
|
+
crass (1.0.6)
|
93
|
+
database_url (0.1.2)
|
94
|
+
devpack (0.4.0)
|
95
|
+
diff-lcs (1.5.0)
|
96
|
+
digest (3.1.0)
|
97
|
+
erubi (1.10.0)
|
98
|
+
erubis (2.7.0)
|
99
|
+
globalid (1.0.0)
|
100
|
+
activesupport (>= 5.0)
|
101
|
+
hashdiff (1.0.1)
|
102
|
+
i18n (1.10.0)
|
103
|
+
concurrent-ruby (~> 1.0)
|
104
|
+
loofah (2.18.0)
|
105
|
+
crass (~> 1.0.2)
|
106
|
+
nokogiri (>= 1.5.9)
|
107
|
+
mail (2.7.1)
|
108
|
+
mini_mime (>= 0.1.1)
|
109
|
+
marcel (1.0.2)
|
110
|
+
method_source (1.0.0)
|
111
|
+
mini_mime (1.1.2)
|
112
|
+
minitest (5.15.0)
|
113
|
+
mongo (2.17.1)
|
114
|
+
bson (>= 4.8.2, < 5.0.0)
|
115
|
+
mongoid (7.4.0)
|
116
|
+
activemodel (>= 5.1, < 7.1, != 7.0.0)
|
117
|
+
mongo (>= 2.10.5, < 3.0.0)
|
118
|
+
ruby2_keywords (~> 0.0.5)
|
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
|
134
|
+
nio4r (2.5.8)
|
135
|
+
nokogiri (1.13.6-x86_64-linux)
|
136
|
+
racc (~> 1.4)
|
137
|
+
paint (2.2.1)
|
138
|
+
parallel (1.22.1)
|
139
|
+
parser (3.1.2.0)
|
140
|
+
ast (~> 2.4.1)
|
141
|
+
pg (1.3.5)
|
142
|
+
public_suffix (4.0.7)
|
143
|
+
racc (1.6.0)
|
144
|
+
rack (2.2.3)
|
145
|
+
rack-test (1.1.0)
|
146
|
+
rack (>= 1.0, < 3)
|
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)
|
159
|
+
bundler (>= 1.15.0)
|
160
|
+
railties (= 7.0.3)
|
161
|
+
rails-dom-testing (2.0.3)
|
162
|
+
activesupport (>= 4.2.0)
|
163
|
+
nokogiri (>= 1.6)
|
164
|
+
rails-html-sanitizer (1.4.2)
|
165
|
+
loofah (~> 2.3)
|
166
|
+
railties (7.0.3)
|
167
|
+
actionpack (= 7.0.3)
|
168
|
+
activesupport (= 7.0.3)
|
169
|
+
method_source
|
170
|
+
rake (>= 12.2)
|
171
|
+
thor (~> 1.0)
|
172
|
+
zeitwerk (~> 2.5)
|
173
|
+
rainbow (3.1.1)
|
174
|
+
rake (13.0.6)
|
175
|
+
rbtree (0.4.5)
|
176
|
+
redis (4.6.0)
|
177
|
+
regexp_parser (2.4.0)
|
178
|
+
rexml (3.2.5)
|
179
|
+
rspec (3.11.0)
|
180
|
+
rspec-core (~> 3.11.0)
|
181
|
+
rspec-expectations (~> 3.11.0)
|
182
|
+
rspec-mocks (~> 3.11.0)
|
183
|
+
rspec-core (3.11.0)
|
184
|
+
rspec-support (~> 3.11.0)
|
185
|
+
rspec-expectations (3.11.0)
|
186
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
187
|
+
rspec-support (~> 3.11.0)
|
188
|
+
rspec-its (1.3.0)
|
189
|
+
rspec-core (>= 3.0.0)
|
190
|
+
rspec-expectations (>= 3.0.0)
|
191
|
+
rspec-mocks (3.11.1)
|
192
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
193
|
+
rspec-support (~> 3.11.0)
|
194
|
+
rspec-support (3.11.0)
|
195
|
+
rubocop (1.30.0)
|
196
|
+
parallel (~> 1.10)
|
197
|
+
parser (>= 3.1.0.0)
|
198
|
+
rainbow (>= 2.2.2, < 4.0)
|
199
|
+
regexp_parser (>= 1.8, < 3.0)
|
200
|
+
rexml (>= 3.2.5, < 4.0)
|
201
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
202
|
+
ruby-progressbar (~> 1.7)
|
203
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
204
|
+
rubocop-ast (1.18.0)
|
205
|
+
parser (>= 3.1.1.0)
|
206
|
+
rubocop-rails (2.14.2)
|
207
|
+
activesupport (>= 4.2.0)
|
208
|
+
rack (>= 1.1)
|
209
|
+
rubocop (>= 1.7.0, < 2.0)
|
210
|
+
rubocop-rake (0.6.0)
|
211
|
+
rubocop (~> 1.0)
|
212
|
+
rubocop-rspec (2.11.1)
|
213
|
+
rubocop (~> 1.19)
|
214
|
+
ruby-progressbar (1.11.0)
|
215
|
+
ruby2_keywords (0.0.5)
|
216
|
+
set (1.0.2)
|
217
|
+
sorted_set (1.0.3)
|
218
|
+
rbtree
|
219
|
+
set (~> 1.0)
|
220
|
+
sqlite3 (1.4.2)
|
221
|
+
strong_versions (0.4.5)
|
222
|
+
i18n (>= 0.5)
|
223
|
+
paint (~> 2.0)
|
224
|
+
strscan (3.0.3)
|
225
|
+
thor (1.2.1)
|
226
|
+
timeout (0.3.0)
|
227
|
+
tzinfo (2.0.4)
|
228
|
+
concurrent-ruby (~> 1.0)
|
229
|
+
unicode-display_width (2.1.0)
|
230
|
+
webmock (3.14.0)
|
231
|
+
addressable (>= 2.8.0)
|
232
|
+
crack (>= 0.3.2)
|
233
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
234
|
+
websocket-driver (0.7.5)
|
235
|
+
websocket-extensions (>= 0.1.0)
|
236
|
+
websocket-extensions (0.1.5)
|
237
|
+
zeitwerk (2.5.4)
|
238
|
+
|
239
|
+
PLATFORMS
|
240
|
+
x86_64-linux
|
241
|
+
|
242
|
+
DEPENDENCIES
|
243
|
+
activerecord (>= 6.0)
|
244
|
+
bunny (~> 2.19)
|
245
|
+
devpack (~> 0.4.0)
|
246
|
+
mongoid (~> 7.4)
|
247
|
+
mysql2 (~> 0.5.3)
|
248
|
+
orchestration!
|
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)
|
260
|
+
strong_versions (~> 0.4.5)
|
261
|
+
webmock (~> 3.14)
|
262
|
+
|
263
|
+
BUNDLED WITH
|
264
|
+
2.3.14
|
data/README.md
CHANGED
@@ -31,13 +31,13 @@ Add _Orchestration_ to your `Gemfile`:
|
|
31
31
|
_Ruby 3.x_:
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
gem 'orchestration', '~> 0.7.
|
34
|
+
gem 'orchestration', '~> 0.7.3'
|
35
35
|
```
|
36
36
|
|
37
37
|
_Ruby 2.x_:
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
gem 'orchestration', '~> 0.6.
|
40
|
+
gem 'orchestration', '~> 0.6.7'
|
41
41
|
```
|
42
42
|
|
43
43
|
Install:
|
@@ -67,6 +67,7 @@ _Orchestration_ generates the following files where appropriate. Backups are cre
|
|
67
67
|
* `config/database.yml`
|
68
68
|
* `config/mongoid.yml`
|
69
69
|
* `config/rabbitmq.yml` (see [RabbitMQ Configuration](#rabbitmq-configuration) for more details)
|
70
|
+
* `config/redis.yml` (see [Redis Configuration](#redis-configuration) for more details)
|
70
71
|
* `config/unicorn.rb`
|
71
72
|
* `config/puma.rb`
|
72
73
|
|
@@ -396,13 +397,6 @@ make stop RAILS_ENV=test
|
|
396
397
|
<a name="rabbitmq-configuration"></a>
|
397
398
|
## RabbitMQ Configuration
|
398
399
|
|
399
|
-
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.:
|
400
|
-
|
401
|
-
```ruby
|
402
|
-
connection = Bunny.new(config_for(:rabbit_mq)['url'])
|
403
|
-
connection.start
|
404
|
-
```
|
405
|
-
|
406
400
|
_Orchestration_ generates the following `config/rabbitmq.yml`:
|
407
401
|
|
408
402
|
```
|
@@ -419,10 +413,42 @@ production:
|
|
419
413
|
management_url: <%= ENV['RABBITMQ_MANAGEMENT_URL'] %>
|
420
414
|
```
|
421
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
|
+
|
422
423
|
Using this approach, the environment variable `RABBITMQ_URL` can be used to configure _Bunny_ in production (similar to `DATABASE_URL` and `MONGO_URL`).
|
423
424
|
|
424
425
|
This is a convention of the _Orchestration_ gem intended to make _RabbitMQ_ configuration consistent with other services.
|
425
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
|
+
|
426
452
|
## Alternate Database Configuration Files
|
427
453
|
|
428
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
|
|
@@ -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
|
@@ -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)
|
@@ -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
|
@@ -72,7 +72,7 @@ module Orchestration
|
|
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
|
@@ -107,7 +107,9 @@ endif
|
|
107
107
|
ifneq (${env},test)
|
108
108
|
ifeq (,$(findstring test,$(MAKECMDGOALS)))
|
109
109
|
ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
|
110
|
-
|
110
|
+
ifeq (,$(findstring setup,$(MAKECMDGOALS)))
|
111
|
+
-include ${env_path}
|
112
|
+
endif
|
111
113
|
endif
|
112
114
|
endif
|
113
115
|
endif
|
@@ -122,7 +124,9 @@ ifneq (,$(findstring test,$(MAKECMDGOALS)))
|
|
122
124
|
env=test
|
123
125
|
endif
|
124
126
|
|
125
|
-
ifneq (,$(
|
127
|
+
ifneq (,$(RAILS_ENV))
|
128
|
+
env=$(RAILS_ENV)
|
129
|
+
else ifneq (,$(env))
|
126
130
|
# `env` set by current shell.
|
127
131
|
else ifneq (,$(RAILS_ENV))
|
128
132
|
env=$(RAILS_ENV)
|
@@ -216,11 +220,16 @@ all: build
|
|
216
220
|
|
217
221
|
### Container management commands ###
|
218
222
|
|
223
|
+
.PHONY: pull
|
224
|
+
pull:
|
225
|
+
@$(call system,${compose_human} pull)
|
226
|
+
@${compose} pull
|
227
|
+
|
219
228
|
.PHONY: start
|
220
229
|
ifndef network
|
221
230
|
start: network := ${compose_project_name}
|
222
231
|
endif
|
223
|
-
start: _create-log-directory _clean-logs
|
232
|
+
start: _create-log-directory _clean-logs pull
|
224
233
|
ifneq (,${compose_services})
|
225
234
|
@$(call system,${compose_human} up --detach)
|
226
235
|
ifeq (${env},$(filter ${env},test development))
|
@@ -312,8 +321,8 @@ setup: _log-notify
|
|
312
321
|
@$(call make,start env=${env})
|
313
322
|
ifneq (,$(wildcard config/database.yml))
|
314
323
|
@$(call echo,Preparing ${env_human} database)
|
315
|
-
@$(call system,rake db:create RAILS_ENV="${env}")
|
316
|
-
@${rake} db:create RAILS_ENV=${env} ${log} || : ${log}
|
324
|
+
@$(call system,rake db:create RAILS_ENV="${env}" DATABASE_URL='${url}')
|
325
|
+
@${rake} db:create RAILS_ENV=${env} DATABASE_URL='${url}' ${log} || : ${log}
|
317
326
|
ifneq (,$(wildcard db/structure.sql))
|
318
327
|
@$(call system,rake db:structure:load RAILS_ENV="${env}" DATABASE_URL="${url}")
|
319
328
|
@${rake} db:structure:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
@@ -322,7 +331,7 @@ ifneq (,$(wildcard config/database.yml))
|
|
322
331
|
@${rake} db:schema:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
323
332
|
endif
|
324
333
|
@$(call system,rake db:migrate RAILS_ENV="${env}" DATABASE_URL="${url}")
|
325
|
-
@${rake} db:migrate RAILS_ENV
|
334
|
+
@${rake} db:migrate RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
326
335
|
endif
|
327
336
|
@if $(MAKE) -n post-setup >/dev/null 2>&1; then \
|
328
337
|
$(call system,make post-setup RAILS_ENV="${env}") \
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orchestration
|
4
|
+
module Services
|
5
|
+
module Redis
|
6
|
+
class Configuration
|
7
|
+
include ConfigurationBase
|
8
|
+
|
9
|
+
self.service_name = 'redis'
|
10
|
+
|
11
|
+
def enabled?
|
12
|
+
defined?(::Redis)
|
13
|
+
end
|
14
|
+
|
15
|
+
def friendly_config
|
16
|
+
"[redis] redis://#{host}:#{port}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def host
|
20
|
+
from_url['host'] || super
|
21
|
+
end
|
22
|
+
|
23
|
+
def port
|
24
|
+
from_url['port'] || super
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def from_url
|
30
|
+
return {} if @env.redis_url.nil?
|
31
|
+
|
32
|
+
uri = URI.parse(@env.redis_url)
|
33
|
+
{ 'host' => uri.host, 'port' => uri.port || PORT }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orchestration
|
4
|
+
module Services
|
5
|
+
module Redis
|
6
|
+
class Healthcheck
|
7
|
+
class NotConnectedError < OrchestrationError; end
|
8
|
+
|
9
|
+
include HealthcheckBase
|
10
|
+
|
11
|
+
dependencies 'redis'
|
12
|
+
|
13
|
+
def connection_errors
|
14
|
+
[NotConnectedError]
|
15
|
+
end
|
16
|
+
|
17
|
+
def connect
|
18
|
+
host = @configuration.host
|
19
|
+
port = @configuration.port
|
20
|
+
return if ::Redis.new(url: "redis://#{host}:#{port}").connected?
|
21
|
+
|
22
|
+
raise NotConnectedError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
environment ENV.fetch('RAILS_ENV'
|
1
|
+
environment ENV.fetch('RAILS_ENV', 'development')
|
2
2
|
|
3
|
-
port ENV.fetch('WEB_PORT'
|
4
|
-
workers ENV.fetch('WEB_CONCURRENCY'
|
5
|
-
threads_count = ENV.fetch('RAILS_MAX_THREADS'
|
3
|
+
port ENV.fetch('WEB_PORT', 3000)
|
4
|
+
workers ENV.fetch('WEB_CONCURRENCY', 4)
|
5
|
+
threads_count = ENV.fetch('RAILS_MAX_THREADS', 8)
|
6
6
|
|
7
7
|
pidfile './tmp/pids/server.pid'
|
8
8
|
threads threads_count, threads_count
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<% if compose.call('development').services.key?('redis') %>
|
2
|
+
development:
|
3
|
+
url: <%= "#{'<' + '%' + '='} ENV.fetch('REDIS_URL', 'redis://127.0.0.1:#{compose.call('development').local_port('redis', 6379)}') #{'%' + '>'}" %>
|
4
|
+
<% end %>
|
5
|
+
|
6
|
+
<% if compose.call('test').services.key?('redis') %>
|
7
|
+
test:
|
8
|
+
url: <%= "#{'<' + '%' + '='} ENV.fetch('REDIS_URL', 'redis://127.0.0.1:#{compose.call('test').local_port('redis', 6379)}') #{'%' + '>'}" %>
|
9
|
+
<% end %>
|
@@ -110,6 +110,9 @@ post-setup:
|
|
110
110
|
namespace :db do
|
111
111
|
desc I18n.t('orchestration.rake.db.url')
|
112
112
|
task :url do
|
113
|
+
ENV['DATABASE_URL'] = nil
|
114
|
+
ENV['DEVELOPMENT_DATABASE_URL'] = nil
|
115
|
+
ENV['TEST_DATABASE_URL'] = nil
|
113
116
|
config = Rails.application.config_for(:database).transform_keys(&:to_sym)
|
114
117
|
|
115
118
|
if config[:adapter] == 'sqlite3'
|
data/orchestration.gemspec
CHANGED
@@ -42,6 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency 'pg', '~> 1.3'
|
43
43
|
spec.add_development_dependency 'rails'
|
44
44
|
spec.add_development_dependency 'rake', '~> 13.0'
|
45
|
+
spec.add_development_dependency 'redis', '~> 4.6'
|
45
46
|
spec.add_development_dependency 'rspec', '~> 3.11'
|
46
47
|
spec.add_development_dependency 'rspec-its', '~> 1.3'
|
47
48
|
spec.add_development_dependency 'rubocop', '~> 1.28'
|
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.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_url
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '13.0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: redis
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '4.6'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '4.6'
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: rspec
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -342,9 +356,11 @@ files:
|
|
342
356
|
- ".gitignore"
|
343
357
|
- ".rspec"
|
344
358
|
- ".rubocop.yml"
|
359
|
+
- ".ruby-version"
|
345
360
|
- ".strong_versions.yml"
|
346
361
|
- ".travis.yml"
|
347
362
|
- Gemfile
|
363
|
+
- Gemfile.lock
|
348
364
|
- LICENSE
|
349
365
|
- Makefile
|
350
366
|
- README.md
|
@@ -365,6 +381,7 @@ files:
|
|
365
381
|
- lib/orchestration/docker_compose/install_generator.rb
|
366
382
|
- lib/orchestration/docker_compose/mongo_service.rb
|
367
383
|
- lib/orchestration/docker_compose/rabbitmq_service.rb
|
384
|
+
- lib/orchestration/docker_compose/redis_service.rb
|
368
385
|
- lib/orchestration/docker_healthcheck.rb
|
369
386
|
- lib/orchestration/environment.rb
|
370
387
|
- lib/orchestration/errors.rb
|
@@ -398,6 +415,9 @@ files:
|
|
398
415
|
- lib/orchestration/services/rabbitmq.rb
|
399
416
|
- lib/orchestration/services/rabbitmq/configuration.rb
|
400
417
|
- lib/orchestration/services/rabbitmq/healthcheck.rb
|
418
|
+
- lib/orchestration/services/redis.rb
|
419
|
+
- lib/orchestration/services/redis/configuration.rb
|
420
|
+
- lib/orchestration/services/redis/healthcheck.rb
|
401
421
|
- lib/orchestration/settings.rb
|
402
422
|
- lib/orchestration/templates/Dockerfile.erb
|
403
423
|
- lib/orchestration/templates/application.mk.erb
|
@@ -407,6 +427,7 @@ files:
|
|
407
427
|
- lib/orchestration/templates/mongoid.yml.erb
|
408
428
|
- lib/orchestration/templates/puma.rb.erb
|
409
429
|
- lib/orchestration/templates/rabbitmq.yml.erb
|
430
|
+
- lib/orchestration/templates/redis.yml.erb
|
410
431
|
- lib/orchestration/templates/unicorn.rb.erb
|
411
432
|
- lib/orchestration/terminal.rb
|
412
433
|
- lib/orchestration/version.rb
|