orchestration 0.6.7 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.strong_versions.yml +1 -0
- data/Gemfile.lock +109 -91
- data/README.md +42 -13
- data/lib/orchestration/docker_compose/app_service.rb +11 -3
- data/lib/orchestration/docker_compose/compose_configuration.rb +2 -2
- 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 +9 -3
- data/lib/orchestration/file_helpers.rb +3 -3
- data/lib/orchestration/install_generator.rb +10 -4
- data/lib/orchestration/make/orchestration.mk +4 -4
- data/lib/orchestration/services/database/configuration.rb +5 -5
- data/lib/orchestration/services/mixins/configuration_base.rb +1 -1
- data/lib/orchestration/services/mixins/http_healthcheck.rb +1 -1
- data/lib/orchestration/services/mongo/configuration.rb +1 -1
- 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/redis.yml.erb +9 -0
- data/lib/orchestration/version.rb +1 -1
- data/lib/tasks/orchestration.rake +1 -1
- data/orchestration.gemspec +22 -21
- metadata +64 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3423dc31e2b526868cb869c930d6f73039437939aa7b2ceb859e0e8106536344
|
4
|
+
data.tar.gz: 4669fd75876e047f52d256dd2f2e3840ecd42f157b04c6f4f81e315ae96ca6ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a4f0579b2698d30103975b175b8a4cdc1df51c5ce883560f2b11f24b8fd3307fd1e6a35868689f6152d182e07ddbc65b6f081fe4b33ae1114e7957b64338c02
|
7
|
+
data.tar.gz: 380413ccb1b108614ad09247a2435178a042c352775712b287c79e707938aa409290ab42f9b0b5d7cc32184fe73de200a8a551ae5c24ba37b3c08655e4caeaf0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.2
|
data/.strong_versions.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,76 +1,82 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
orchestration (0.
|
4
|
+
orchestration (0.7.2)
|
5
5
|
database_url (~> 0.1.2)
|
6
6
|
erubis (~> 2.7)
|
7
|
-
i18n
|
8
|
-
paint (~> 2.
|
9
|
-
rails (>=
|
10
|
-
thor (~> 1.
|
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 (
|
16
|
-
actionpack (=
|
17
|
-
activesupport (=
|
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 (
|
21
|
-
actionpack (=
|
22
|
-
activejob (=
|
23
|
-
activerecord (=
|
24
|
-
activestorage (=
|
25
|
-
activesupport (=
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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 (
|
35
|
-
actionview (=
|
36
|
-
activesupport (=
|
37
|
-
rack (~> 2.0, >= 2.0
|
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 (
|
42
|
-
actionpack (=
|
43
|
-
activerecord (=
|
44
|
-
activestorage (=
|
45
|
-
activesupport (=
|
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 (
|
48
|
-
activesupport (=
|
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 (
|
54
|
-
activesupport (=
|
60
|
+
activejob (7.0.3)
|
61
|
+
activesupport (= 7.0.3)
|
55
62
|
globalid (>= 0.3.6)
|
56
|
-
activemodel (
|
57
|
-
activesupport (=
|
58
|
-
activerecord (
|
59
|
-
activemodel (=
|
60
|
-
activesupport (=
|
61
|
-
activestorage (
|
62
|
-
actionpack (=
|
63
|
-
activejob (=
|
64
|
-
activerecord (=
|
65
|
-
activesupport (=
|
66
|
-
marcel (~> 1.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 (
|
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.
|
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 (
|
127
|
-
actioncable (=
|
128
|
-
actionmailbox (=
|
129
|
-
actionmailer (=
|
130
|
-
actionpack (=
|
131
|
-
actiontext (=
|
132
|
-
actionview (=
|
133
|
-
activejob (=
|
134
|
-
activemodel (=
|
135
|
-
activerecord (=
|
136
|
-
activestorage (=
|
137
|
-
activesupport (=
|
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 (=
|
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 (
|
147
|
-
actionpack (=
|
148
|
-
activesupport (=
|
166
|
+
railties (7.0.3)
|
167
|
+
actionpack (= 7.0.3)
|
168
|
+
activesupport (= 7.0.3)
|
149
169
|
method_source
|
150
|
-
rake (>=
|
170
|
+
rake (>= 12.2)
|
151
171
|
thor (~> 1.0)
|
172
|
+
zeitwerk (~> 2.5)
|
152
173
|
rainbow (3.1.1)
|
153
|
-
rake (
|
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.
|
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 (
|
227
|
-
bunny (~> 2.
|
228
|
-
devpack (~> 0.
|
229
|
-
mongoid (~> 7.
|
230
|
-
mysql2 (~> 0.5.
|
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.
|
233
|
-
rails
|
234
|
-
rake (~>
|
235
|
-
|
236
|
-
rspec
|
237
|
-
|
238
|
-
rubocop
|
239
|
-
rubocop-
|
240
|
-
rubocop-
|
241
|
-
|
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.
|
261
|
+
webmock (~> 3.14)
|
244
262
|
|
245
263
|
BUNDLED WITH
|
246
|
-
2.3.
|
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
|
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
|
80
|
+
{ local:, remote: }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -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')
|
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')
|
24
|
+
ENV.fetch('DEVELOPMENT_DATABASE_URL', nil) || ENV.fetch('DATABASE_URL', nil)
|
24
25
|
when 'test'
|
25
|
-
ENV.fetch('TEST_DATABASE_URL')
|
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
|
98
|
+
return if line_in_file?(path, line:, regex:)
|
99
99
|
|
100
|
-
append_file(path, "\n#{line.chomp}\n", 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
|
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:
|
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}"
|
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}"
|
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}"
|
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 \
|