orchestration 0.6.4 → 0.6.7
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/.strong_versions.yml +1 -0
- data/Gemfile.lock +246 -0
- data/README.md +1 -1
- data/UPGRADE.md +22 -2
- data/config/locales/en.yml +1 -0
- data/lib/orchestration/docker_compose/app_service.rb +2 -4
- data/lib/orchestration/docker_compose/compose_configuration.rb +2 -0
- data/lib/orchestration/docker_compose/compose_helpers.rb +6 -0
- data/lib/orchestration/docker_compose/database_service.rb +0 -6
- data/lib/orchestration/docker_compose/mongo_service.rb +1 -1
- data/lib/orchestration/docker_compose/rabbitmq_service.rb +1 -1
- data/lib/orchestration/environment.rb +5 -5
- data/lib/orchestration/make/orchestration.mk +34 -26
- data/lib/orchestration/templates/Dockerfile.erb +1 -1
- data/lib/orchestration/templates/application.mk.erb +3 -6
- data/lib/orchestration/templates/rabbitmq.yml.erb +1 -1
- data/lib/orchestration/terminal.rb +4 -0
- data/lib/orchestration/version.rb +1 -1
- data/lib/orchestration.rb +1 -0
- data/lib/tasks/orchestration.rake +95 -2
- data/orchestration.gemspec +2 -2
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cb2b72a148e2687680311cd050b426ccd06c063e4ab01e0affc03be0afbc16d
|
4
|
+
data.tar.gz: 97210bd8c3133b7d246ed4b8cd92f56c148a91c283b3ad51f8c4d61e8d6ed690
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 751f8433ec5094ee87639115d4c0f43e14ed0d7f2c5382fd8d79dd050d9ae27073f962304776d83d74e2b57bb97ae3e2bf774fff9a967a0b534e950462914689
|
7
|
+
data.tar.gz: 19b986c4ec255c2f451d99616d310235e10abcf8c403f87ef02bd1b5551da4189fdf7bf72be47f07499ed12142193b7d16e3c67b803f6c0951c6227d02d9b380
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.9
|
data/.strong_versions.yml
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,246 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
orchestration (0.6.7)
|
5
|
+
database_url (~> 0.1.2)
|
6
|
+
erubis (~> 2.7)
|
7
|
+
i18n (>= 0.5)
|
8
|
+
paint (~> 2.0)
|
9
|
+
rails (>= 4.1)
|
10
|
+
thor (~> 1.0)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
actioncable (6.1.4.7)
|
16
|
+
actionpack (= 6.1.4.7)
|
17
|
+
activesupport (= 6.1.4.7)
|
18
|
+
nio4r (~> 2.0)
|
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)
|
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)
|
32
|
+
mail (~> 2.5, >= 2.5.4)
|
33
|
+
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)
|
38
|
+
rack-test (>= 0.6.3)
|
39
|
+
rails-dom-testing (~> 2.0)
|
40
|
+
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)
|
46
|
+
nokogiri (>= 1.8.5)
|
47
|
+
actionview (6.1.4.7)
|
48
|
+
activesupport (= 6.1.4.7)
|
49
|
+
builder (~> 3.1)
|
50
|
+
erubi (~> 1.4)
|
51
|
+
rails-dom-testing (~> 2.0)
|
52
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
53
|
+
activejob (6.1.4.7)
|
54
|
+
activesupport (= 6.1.4.7)
|
55
|
+
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)
|
67
|
+
mini_mime (>= 1.1.0)
|
68
|
+
activesupport (6.1.4.7)
|
69
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
70
|
+
i18n (>= 1.6, < 2)
|
71
|
+
minitest (>= 5.1)
|
72
|
+
tzinfo (~> 2.0)
|
73
|
+
zeitwerk (~> 2.3)
|
74
|
+
addressable (2.8.0)
|
75
|
+
public_suffix (>= 2.0.2, < 5.0)
|
76
|
+
amq-protocol (2.3.2)
|
77
|
+
ast (2.4.2)
|
78
|
+
bson (4.15.0)
|
79
|
+
builder (3.2.4)
|
80
|
+
bunny (2.19.0)
|
81
|
+
amq-protocol (~> 2.3, >= 2.3.1)
|
82
|
+
sorted_set (~> 1, >= 1.0.2)
|
83
|
+
concurrent-ruby (1.1.10)
|
84
|
+
crack (0.4.5)
|
85
|
+
rexml
|
86
|
+
crass (1.0.6)
|
87
|
+
database_url (0.1.2)
|
88
|
+
devpack (0.3.3)
|
89
|
+
diff-lcs (1.5.0)
|
90
|
+
erubi (1.10.0)
|
91
|
+
erubis (2.7.0)
|
92
|
+
globalid (1.0.0)
|
93
|
+
activesupport (>= 5.0)
|
94
|
+
hashdiff (1.0.1)
|
95
|
+
i18n (1.10.0)
|
96
|
+
concurrent-ruby (~> 1.0)
|
97
|
+
loofah (2.18.0)
|
98
|
+
crass (~> 1.0.2)
|
99
|
+
nokogiri (>= 1.5.9)
|
100
|
+
mail (2.7.1)
|
101
|
+
mini_mime (>= 0.1.1)
|
102
|
+
marcel (1.0.2)
|
103
|
+
method_source (1.0.0)
|
104
|
+
mini_mime (1.1.2)
|
105
|
+
minitest (5.15.0)
|
106
|
+
mongo (2.17.1)
|
107
|
+
bson (>= 4.8.2, < 5.0.0)
|
108
|
+
mongoid (7.4.0)
|
109
|
+
activemodel (>= 5.1, < 7.1, != 7.0.0)
|
110
|
+
mongo (>= 2.10.5, < 3.0.0)
|
111
|
+
ruby2_keywords (~> 0.0.5)
|
112
|
+
mysql2 (0.5.4)
|
113
|
+
nio4r (2.5.8)
|
114
|
+
nokogiri (1.13.6-x86_64-linux)
|
115
|
+
racc (~> 1.4)
|
116
|
+
paint (2.2.1)
|
117
|
+
parallel (1.22.1)
|
118
|
+
parser (3.1.2.0)
|
119
|
+
ast (~> 2.4.1)
|
120
|
+
pg (1.3.5)
|
121
|
+
public_suffix (4.0.7)
|
122
|
+
racc (1.6.0)
|
123
|
+
rack (2.2.3)
|
124
|
+
rack-test (1.1.0)
|
125
|
+
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)
|
138
|
+
bundler (>= 1.15.0)
|
139
|
+
railties (= 6.1.4.7)
|
140
|
+
sprockets-rails (>= 2.0.0)
|
141
|
+
rails-dom-testing (2.0.3)
|
142
|
+
activesupport (>= 4.2.0)
|
143
|
+
nokogiri (>= 1.6)
|
144
|
+
rails-html-sanitizer (1.4.2)
|
145
|
+
loofah (~> 2.3)
|
146
|
+
railties (6.1.4.7)
|
147
|
+
actionpack (= 6.1.4.7)
|
148
|
+
activesupport (= 6.1.4.7)
|
149
|
+
method_source
|
150
|
+
rake (>= 0.13)
|
151
|
+
thor (~> 1.0)
|
152
|
+
rainbow (3.1.1)
|
153
|
+
rake (10.5.0)
|
154
|
+
rbtree (0.4.5)
|
155
|
+
regexp_parser (2.4.0)
|
156
|
+
rexml (3.2.5)
|
157
|
+
rspec (3.11.0)
|
158
|
+
rspec-core (~> 3.11.0)
|
159
|
+
rspec-expectations (~> 3.11.0)
|
160
|
+
rspec-mocks (~> 3.11.0)
|
161
|
+
rspec-core (3.11.0)
|
162
|
+
rspec-support (~> 3.11.0)
|
163
|
+
rspec-expectations (3.11.0)
|
164
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
165
|
+
rspec-support (~> 3.11.0)
|
166
|
+
rspec-its (1.3.0)
|
167
|
+
rspec-core (>= 3.0.0)
|
168
|
+
rspec-expectations (>= 3.0.0)
|
169
|
+
rspec-mocks (3.11.1)
|
170
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
171
|
+
rspec-support (~> 3.11.0)
|
172
|
+
rspec-support (3.11.0)
|
173
|
+
rubocop (1.30.0)
|
174
|
+
parallel (~> 1.10)
|
175
|
+
parser (>= 3.1.0.0)
|
176
|
+
rainbow (>= 2.2.2, < 4.0)
|
177
|
+
regexp_parser (>= 1.8, < 3.0)
|
178
|
+
rexml (>= 3.2.5, < 4.0)
|
179
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
180
|
+
ruby-progressbar (~> 1.7)
|
181
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
182
|
+
rubocop-ast (1.18.0)
|
183
|
+
parser (>= 3.1.1.0)
|
184
|
+
rubocop-rails (2.14.2)
|
185
|
+
activesupport (>= 4.2.0)
|
186
|
+
rack (>= 1.1)
|
187
|
+
rubocop (>= 1.7.0, < 2.0)
|
188
|
+
rubocop-rake (0.5.1)
|
189
|
+
rubocop
|
190
|
+
rubocop-rspec (2.11.1)
|
191
|
+
rubocop (~> 1.19)
|
192
|
+
ruby-progressbar (1.11.0)
|
193
|
+
ruby2_keywords (0.0.5)
|
194
|
+
set (1.0.2)
|
195
|
+
sorted_set (1.0.3)
|
196
|
+
rbtree
|
197
|
+
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
|
+
sqlite3 (1.4.2)
|
206
|
+
strong_versions (0.4.5)
|
207
|
+
i18n (>= 0.5)
|
208
|
+
paint (~> 2.0)
|
209
|
+
thor (1.2.1)
|
210
|
+
tzinfo (2.0.4)
|
211
|
+
concurrent-ruby (~> 1.0)
|
212
|
+
unicode-display_width (2.1.0)
|
213
|
+
webmock (3.14.0)
|
214
|
+
addressable (>= 2.8.0)
|
215
|
+
crack (>= 0.3.2)
|
216
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
217
|
+
websocket-driver (0.7.5)
|
218
|
+
websocket-extensions (>= 0.1.0)
|
219
|
+
websocket-extensions (0.1.5)
|
220
|
+
zeitwerk (2.5.4)
|
221
|
+
|
222
|
+
PLATFORMS
|
223
|
+
x86_64-linux
|
224
|
+
|
225
|
+
DEPENDENCIES
|
226
|
+
activerecord (~> 6.0)
|
227
|
+
bunny (~> 2.12)
|
228
|
+
devpack (~> 0.3.2)
|
229
|
+
mongoid (~> 7.0)
|
230
|
+
mysql2 (~> 0.5.2)
|
231
|
+
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)
|
242
|
+
strong_versions (~> 0.4.5)
|
243
|
+
webmock (~> 3.4)
|
244
|
+
|
245
|
+
BUNDLED WITH
|
246
|
+
2.3.11
|
data/README.md
CHANGED
data/UPGRADE.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
|
-
# Upgrade guide
|
1
|
+
# Upgrade guide (0.5 to 0.6)
|
2
2
|
|
3
|
-
##
|
3
|
+
## Automatic Upgrade
|
4
|
+
|
5
|
+
A _Rake_ task is provided to automatically upgrade your application:
|
6
|
+
|
7
|
+
```bash
|
8
|
+
bundle exec rake orchestration:upgrade
|
9
|
+
```
|
10
|
+
|
11
|
+
Obsolete files will be removed and required modifications to existing files will be applied.
|
12
|
+
|
13
|
+
It is recommended to manually verify the validity of all changes to ensure that no custom configuration is lost.
|
14
|
+
|
15
|
+
## Manual Upgrade
|
4
16
|
|
5
17
|
### Delete/rename files
|
6
18
|
|
@@ -48,6 +60,14 @@ post-setup:
|
|
48
60
|
|
49
61
|
Replace the body of this target with any commands that you want to take place once the initial setup (launching development/test containers, running migrations, etc.) is complete. For example, running migrations for a secondary database.
|
50
62
|
|
63
|
+
### Update Dockerfile healthcheck
|
64
|
+
|
65
|
+
Edit `orchestration/Dockerfile` and edit the `HEALTHCHECK` directive's `CMD` to:
|
66
|
+
|
67
|
+
```
|
68
|
+
CMD ["bundle","exec","rake","orchestration:healthcheck"]
|
69
|
+
```
|
70
|
+
|
51
71
|
### Continuous Integration files
|
52
72
|
|
53
73
|
Update any continuous integration scripts (e.g. `Jenkinsfile`) to run the `setup` target before `test`, e.g.:
|
data/config/locales/en.yml
CHANGED
@@ -28,6 +28,7 @@ en:
|
|
28
28
|
|
29
29
|
rake:
|
30
30
|
config: "Parse and output Orchestration config (internal use)"
|
31
|
+
upgrade: "Upgrade from Orchestration 0.5.x to 0.6.x"
|
31
32
|
healthcheck: "Execute healthcheck; used for HEALTHCHECK command in Docker image"
|
32
33
|
compose_services: "Output configured services for a given environment (RAILS_ENV)"
|
33
34
|
install: "Install Orchestration tools"
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Orchestration
|
4
4
|
module DockerCompose
|
5
5
|
class AppService
|
6
|
+
include ComposeHelpers
|
7
|
+
|
6
8
|
def initialize(config, environment)
|
7
9
|
@environment = environment
|
8
10
|
@config = config
|
@@ -89,10 +91,6 @@ module Orchestration
|
|
89
91
|
}
|
90
92
|
end
|
91
93
|
|
92
|
-
def networks
|
93
|
-
{ 'local' => {} }
|
94
|
-
end
|
95
|
-
|
96
94
|
def environment
|
97
95
|
{
|
98
96
|
'RAILS_LOG_TO_STDOUT' => '1',
|
@@ -13,6 +13,12 @@ module Orchestration
|
|
13
13
|
# "3306" (docker will use an ephemeral host port which we will not use)
|
14
14
|
"${sidecar-#{port}:}"
|
15
15
|
end
|
16
|
+
|
17
|
+
def networks
|
18
|
+
service = self.class.name.rpartition('::').last.partition('Service').first.downcase
|
19
|
+
network_alias = %i[development test].include?(@environment) ? service : "#{service}-local"
|
20
|
+
{ 'local' => { 'aliases' => [network_alias] } }
|
21
|
+
end
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
@@ -33,12 +33,6 @@ module Orchestration
|
|
33
33
|
adapter.default_port
|
34
34
|
end
|
35
35
|
|
36
|
-
def networks
|
37
|
-
return {} unless @environment == :deployment
|
38
|
-
|
39
|
-
{ 'local' => { 'aliases' => ['database-local'] } }
|
40
|
-
end
|
41
|
-
|
42
36
|
def ports
|
43
37
|
return {} unless %i[development test].include?(@environment)
|
44
38
|
|
@@ -9,7 +9,7 @@ module Orchestration
|
|
9
9
|
def environment
|
10
10
|
return @environment unless @environment.nil?
|
11
11
|
|
12
|
-
ENV
|
12
|
+
ENV.fetch('RAILS_ENV') { ENV.fetch('RACK_ENV', 'development') }
|
13
13
|
end
|
14
14
|
|
15
15
|
def web_server
|
@@ -20,16 +20,16 @@ module Orchestration
|
|
20
20
|
def database_url
|
21
21
|
case environment
|
22
22
|
when 'development'
|
23
|
-
ENV
|
23
|
+
ENV.fetch('DEVELOPMENT_DATABASE_URL') { ENV.fetch('DATABASE_URL', nil) }
|
24
24
|
when 'test'
|
25
|
-
ENV
|
25
|
+
ENV.fetch('TEST_DATABASE_URL') { ENV.fetch('DATABASE_URL', nil) }
|
26
26
|
else
|
27
|
-
ENV
|
27
|
+
ENV.fetch('DATABASE_URL', nil)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def mongo_url
|
32
|
-
ENV
|
32
|
+
ENV.fetch('MONGO_URL', nil)
|
33
33
|
end
|
34
34
|
|
35
35
|
def mongoid_configuration_path
|
@@ -99,13 +99,23 @@ exit_fail=( \
|
|
99
99
|
)
|
100
100
|
|
101
101
|
ifdef env_file
|
102
|
-
|
102
|
+
env_path=${env_file}
|
103
103
|
else
|
104
|
-
|
105
|
-
ifeq (,$(findstring test,$(MAKECMDGOALS)))
|
106
|
-
-include .env
|
104
|
+
env_path=.env
|
107
105
|
endif
|
106
|
+
|
107
|
+
ifneq (${env},test)
|
108
|
+
ifeq (,$(findstring test,$(MAKECMDGOALS)))
|
109
|
+
ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
|
110
|
+
ifeq (,$(findstring setup,$(MAKECMDGOALS)))
|
111
|
+
-include ${env_path}
|
112
|
+
endif
|
113
|
+
endif
|
114
|
+
endif
|
108
115
|
endif
|
116
|
+
|
117
|
+
ifneq (,$(findstring deploy,$(MAKECMDGOALS)))
|
118
|
+
RAILS_ENV=$(shell grep '^RAILS_ENV=' '${env_path}' | tail -n1 | sed 's/^RAILS_ENV=//')
|
109
119
|
endif
|
110
120
|
|
111
121
|
export
|
@@ -114,7 +124,9 @@ ifneq (,$(findstring test,$(MAKECMDGOALS)))
|
|
114
124
|
env=test
|
115
125
|
endif
|
116
126
|
|
117
|
-
ifneq (,$(
|
127
|
+
ifneq (,$(RAILS_ENV))
|
128
|
+
env=$(RAILS_ENV)
|
129
|
+
else ifneq (,$(env))
|
118
130
|
# `env` set by current shell.
|
119
131
|
else ifneq (,$(RAILS_ENV))
|
120
132
|
env=$(RAILS_ENV)
|
@@ -130,11 +142,13 @@ DOCKER_TAG ?= latest
|
|
130
142
|
ifneq (,$(wildcard ./Gemfile))
|
131
143
|
bundle_cmd = bundle exec
|
132
144
|
endif
|
133
|
-
rake=DEVPACK_DISABLE=1 RACK_ENV=${env} RAILS_ENV=${env} ${bundle_cmd} rake
|
145
|
+
rake=DEVPACK_DISABLE=1 RACK_ENV=${env} SECRET_KEY_BASE='placeholder-secret' RAILS_ENV=${env} ${bundle_cmd} rake
|
134
146
|
|
135
147
|
ifneq (,$(wildcard ${env_file}))
|
136
|
-
|
137
|
-
|
148
|
+
ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
|
149
|
+
rake_cmd:=${rake}
|
150
|
+
rake=. ${env_file} && ${rake_cmd}
|
151
|
+
endif
|
138
152
|
endif
|
139
153
|
|
140
154
|
docker_config:=$(shell DEVPACK_DISABLE=1 RAILS_ENV=development ${bundle_cmd} rake orchestration:config 2>/dev/null || echo no-org no-repo)
|
@@ -214,7 +228,7 @@ start: _create-log-directory _clean-logs
|
|
214
228
|
ifneq (,${compose_services})
|
215
229
|
@$(call system,${compose_human} up --detach)
|
216
230
|
ifeq (${env},$(filter ${env},test development))
|
217
|
-
|
231
|
+
@${compose} up --detach --force-recreate --renew-anon-volumes --remove-orphans ${services} ${log} || ${exit_fail}
|
218
232
|
@[ -n '${sidecar}' ] && \
|
219
233
|
( \
|
220
234
|
$(call echo,(joining dependency network ${cyan}${network}${reset})) ; \
|
@@ -295,27 +309,27 @@ db-console:
|
|
295
309
|
|
296
310
|
.PHONY: setup
|
297
311
|
ifneq (,$(wildcard config/database.yml))
|
298
|
-
setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env})
|
312
|
+
setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env} 2>/dev/null)
|
299
313
|
endif
|
300
314
|
setup: _log-notify
|
301
315
|
@$(call echo,Setting up ${env_human} environment)
|
302
316
|
@$(call make,start env=${env})
|
303
317
|
ifneq (,$(wildcard config/database.yml))
|
304
318
|
@$(call echo,Preparing ${env_human} database)
|
305
|
-
@$(call system,rake db:create
|
306
|
-
@${rake} db:create RAILS_ENV=${env} ${log} || : ${log}
|
319
|
+
@$(call system,rake db:create RAILS_ENV="${env}")
|
320
|
+
@${rake} db:create RAILS_ENV=${env} DATABASE_URL='${url}' ${log} || : ${log}
|
307
321
|
ifneq (,$(wildcard db/structure.sql))
|
308
|
-
@$(call system,rake db:
|
309
|
-
@${rake} db:
|
322
|
+
@$(call system,rake db:structure:load RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
|
323
|
+
@${rake} db:structure:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
310
324
|
else ifneq (,$(wildcard db/schema.rb))
|
311
|
-
@$(call system,rake db:schema:load DATABASE_URL="${url}")
|
312
|
-
@${rake} db:schema:load DATABASE_URL='${url}' ${log} || ${exit_fail}
|
325
|
+
@$(call system,rake db:schema:load RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
|
326
|
+
@${rake} db:schema:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
313
327
|
endif
|
314
|
-
@$(call system,rake db:migrate DATABASE_URL="${url}")
|
315
|
-
@${rake} db:migrate RAILS_ENV
|
328
|
+
@$(call system,rake db:migrate RAILS_ENV="${env}" ${url_prefix}DATABASE_URL="${url}")
|
329
|
+
@${rake} db:migrate RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
316
330
|
endif
|
317
331
|
@if $(MAKE) -n post-setup >/dev/null 2>&1; then \
|
318
|
-
$(call system,make post-setup RAILS_ENV
|
332
|
+
$(call system,make post-setup RAILS_ENV="${env}") \
|
319
333
|
&& $(MAKE) post-setup RAILS_ENV=${env}; fi
|
320
334
|
@$(call echo,${env_human} environment setup complete ${tick})
|
321
335
|
|
@@ -422,15 +436,9 @@ wait-listener:
|
|
422
436
|
build: _log-notify _clean-logs
|
423
437
|
build: build_dir = ${orchestration_dir}/.build
|
424
438
|
build: context = ${build_dir}/context.tar
|
425
|
-
build: build_args := --build-arg GIT_COMMIT='${git_version}'
|
439
|
+
build: build_args := --build-arg GIT_COMMIT='${git_version}' $(shell grep '^ARG ' orchestration/Dockerfile | sed -e 's/=.*$$//' -e 's/^ARG /--build-arg /')
|
426
440
|
build: tag_human = ${cyan}${docker_organization}/${docker_repository}:${git_version}${reset}
|
427
441
|
build: latest_tag_human = ${cyan}${docker_organization}/${docker_repository}:latest${reset}
|
428
|
-
ifdef BUNDLE_GITHUB__COM
|
429
|
-
build: build_args := ${build_args} --build-arg BUNDLE_GITHUB__COM
|
430
|
-
endif
|
431
|
-
ifdef BUNDLE_BITBUCKET__ORG
|
432
|
-
build: build_args := ${build_args} --build-arg BUNDLE_BITBUCKET__ORG
|
433
|
-
endif
|
434
442
|
build: _create-log-directory check-local-changes
|
435
443
|
@$(call echo,Preparing build context from ${cyan}${git_branch}${reset} (${cyan}${git_version}${reset})${reset})
|
436
444
|
@$(call system,git archive --format "tar" -o "${context}" "${git_branch}")
|
@@ -23,7 +23,7 @@ RUN bundle config set deployment 'true' \
|
|
23
23
|
&& bundle config set without 'development test' \
|
24
24
|
&& bundle install
|
25
25
|
ADD .build/context.tar .
|
26
|
-
<% if defined?(Webpacker) %>RUN . /root/.bashrc ; NODE_ENV=production RAILS_ENV=production yarn install && NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=
|
26
|
+
<% if defined?(Webpacker) %>RUN . /root/.bashrc ; NODE_ENV=production RAILS_ENV=production yarn install && NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=placeholder-secret bundle exec rake assets:precompile<% elsif Rake::Task.tasks.map(&:name).include?('assets:precompile') %>RUN NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=placeholder-secret bundle exec rake assets:precompile<% end %>
|
27
27
|
RUN echo "${GIT_COMMIT}" > /app/GIT_COMMIT
|
28
28
|
HEALTHCHECK --interval=<%= healthcheck['interval'] %> \
|
29
29
|
--timeout=<%= healthcheck['timeout'] %> \
|
@@ -30,11 +30,8 @@ post-setup:
|
|
30
30
|
# Launch all dependencies needed for a development environment and set up the
|
31
31
|
# development database.
|
32
32
|
#
|
33
|
-
.PHONY:
|
33
|
+
.PHONY: develop
|
34
34
|
develop:
|
35
35
|
bundle install
|
36
|
-
@$(MAKE)
|
37
|
-
@$(MAKE)
|
38
|
-
bundle exec rake db:create
|
39
|
-
bundle exec rake db:migrate
|
40
|
-
bundle exec rake db:seed
|
36
|
+
@$(MAKE) setup env=test
|
37
|
+
@$(MAKE) setup env=development
|
@@ -3,9 +3,13 @@
|
|
3
3
|
module Orchestration
|
4
4
|
COLOR_MAP = {
|
5
5
|
failure: %i[red bright],
|
6
|
+
success: %i[green],
|
7
|
+
info: %i[blue],
|
6
8
|
error: %i[red],
|
7
9
|
ready: %i[green],
|
8
10
|
create: %i[green],
|
11
|
+
delete: %i[red],
|
12
|
+
rename: %i[blue],
|
9
13
|
update: %i[yellow],
|
10
14
|
backup: %i[blue],
|
11
15
|
status: %i[blue],
|
data/lib/orchestration.rb
CHANGED
@@ -19,13 +19,106 @@ namespace :orchestration do
|
|
19
19
|
puts "#{config['docker']['organization']} #{config['docker']['repository']}"
|
20
20
|
end
|
21
21
|
|
22
|
+
desc I18n.t('orchestration.rake.upgrade')
|
23
|
+
task :upgrade do
|
24
|
+
terminal = Orchestration::Terminal.new(Orchestration::Environment.new.settings)
|
25
|
+
%w[
|
26
|
+
orchestration/docker-compose.yml
|
27
|
+
orchestration/docker-compose.override.yml
|
28
|
+
orchestration/Makefile
|
29
|
+
orchestration/deploy.mk
|
30
|
+
orchestration/yaml.bash
|
31
|
+
orchestration/healthcheck.rb
|
32
|
+
].each.map { |path| Pathname.new(path) }.each do |path|
|
33
|
+
next unless path.exist?
|
34
|
+
|
35
|
+
terminal.write(:delete, path)
|
36
|
+
path.unlink
|
37
|
+
end
|
38
|
+
|
39
|
+
src = 'orchestration/docker-compose.production.yml'
|
40
|
+
dest = 'orchestration/docker-compose.deployment.yml'
|
41
|
+
if File.exist?(src)
|
42
|
+
terminal.write(:rename, "#{src} => #{dest}")
|
43
|
+
File.rename(src, dest)
|
44
|
+
end
|
45
|
+
|
46
|
+
makefile = File.read('Makefile')
|
47
|
+
makefile.gsub!(
|
48
|
+
%r{^include orchestration/Makefile$},
|
49
|
+
%[include $(shell bundle exec ruby -e 'require "orchestration/make"')]
|
50
|
+
)
|
51
|
+
makefile.gsub!(/^test: test-setup$/, 'test:')
|
52
|
+
lines = makefile.lines(chomp: true)
|
53
|
+
post_setup_start = lines.index('ifndef light')
|
54
|
+
if post_setup_start.nil?
|
55
|
+
updated_makefile = lines.join("\n")
|
56
|
+
post_setup = []
|
57
|
+
else
|
58
|
+
post_setup_end = post_setup_start + lines[post_setup_start..].index('endif')
|
59
|
+
post_setup = lines[(post_setup_start + 1)...post_setup_end]
|
60
|
+
updated_makefile = lines.each.with_index.reject do |_line, index|
|
61
|
+
(post_setup_start..post_setup_end).cover?(index)
|
62
|
+
end.map(&:first).join("\n")
|
63
|
+
end
|
64
|
+
if makefile.match(/^post-setup:$/).nil?
|
65
|
+
updated_makefile += %(
|
66
|
+
|
67
|
+
.PHONY: post-setup
|
68
|
+
post-setup:
|
69
|
+
@# Setup tasks that are not already provided by Orchestration go here.
|
70
|
+
#{post_setup.join("\n")}
|
71
|
+
)
|
72
|
+
end
|
73
|
+
if updated_makefile != makefile
|
74
|
+
terminal.write(:update, 'Makefile')
|
75
|
+
File.write('Makefile', updated_makefile)
|
76
|
+
end
|
77
|
+
|
78
|
+
%w[orchestration/docker-compose.test.yml orchestration/docker-compose.development.yml].each do |path|
|
79
|
+
terminal.write(:update, path)
|
80
|
+
config = YAML.safe_load(File.read(path))
|
81
|
+
config['networks'] ||= {}
|
82
|
+
config['networks']['local'] = { 'name' => '${COMPOSE_PROJECT_NAME}' }
|
83
|
+
config['services'] ||= {}
|
84
|
+
config['services'].each do |name, service|
|
85
|
+
service['networks'] = { 'local' => { 'aliases' => [name] } }
|
86
|
+
end
|
87
|
+
File.write(path, config.to_yaml)
|
88
|
+
end
|
89
|
+
|
90
|
+
dockerfile_path = 'orchestration/Dockerfile'
|
91
|
+
dockerfile = File.read(dockerfile_path)
|
92
|
+
updated_dockerfile = dockerfile.dup
|
93
|
+
updated_dockerfile.gsub!(
|
94
|
+
'CMD ["ruby","/app/orchestration/healthcheck.rb"]',
|
95
|
+
'CMD ["bundle","exec","rake","orchestration:healthcheck"]'
|
96
|
+
)
|
97
|
+
if updated_dockerfile != dockerfile
|
98
|
+
terminal.write(:update, dockerfile_path)
|
99
|
+
File.write(dockerfile_path, updated_dockerfile)
|
100
|
+
end
|
101
|
+
|
102
|
+
terminal.write(:success, 'Upgrade complete.')
|
103
|
+
terminal.write(:info, '`make test` will now only run tests, skipping setup.')
|
104
|
+
terminal.write(:info, 'Run `make setup test` to load test containers, run migrations, etc.')
|
105
|
+
terminal.write(:info, 'Run `make setup` to load development environment.')
|
106
|
+
terminal.write(:info, 'Run `make setup RAILS_ENV=test` to load test environment without running tests.')
|
107
|
+
terminal.write(:info, 'Edit the `post-setup` recipe in `Makefile` to perform custom setup actions.')
|
108
|
+
end
|
109
|
+
|
22
110
|
namespace :db do
|
23
111
|
desc I18n.t('orchestration.rake.db.url')
|
24
112
|
task :url do
|
25
|
-
|
113
|
+
ENV['DATABASE_URL'] = nil
|
114
|
+
ENV['DEVELOPMENT_DATABASE_URL'] = nil
|
115
|
+
ENV['TEST_DATABASE_URL'] = nil
|
116
|
+
config = Rails.application.config_for(:database).transform_keys(&:to_sym)
|
26
117
|
|
27
118
|
if config[:adapter] == 'sqlite3'
|
28
119
|
puts "sqlite3:#{config[:database]}"
|
120
|
+
elsif !config[:url].nil?
|
121
|
+
puts config[:url]
|
29
122
|
else
|
30
123
|
puts DatabaseUrl.to_active_record_url(config)
|
31
124
|
end
|
@@ -71,7 +164,7 @@ namespace :orchestration do
|
|
71
164
|
end
|
72
165
|
|
73
166
|
adapter::Healthcheck.start(
|
74
|
-
nil, nil, config_path: path, service_name: name, sidecar: ENV
|
167
|
+
nil, nil, config_path: path, service_name: name, sidecar: ENV.fetch('sidecar', nil)
|
75
168
|
)
|
76
169
|
end
|
77
170
|
end
|
data/orchestration.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
spec.required_ruby_version = '
|
25
|
+
spec.required_ruby_version = '>= 2.6'
|
26
26
|
spec.bindir = 'bin'
|
27
27
|
spec.executables = []
|
28
28
|
spec.require_paths = ['lib']
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_runtime_dependency 'erubis', '~> 2.7'
|
32
32
|
spec.add_runtime_dependency 'i18n', '>= 0.5'
|
33
33
|
spec.add_runtime_dependency 'paint', '~> 2.0'
|
34
|
-
spec.add_runtime_dependency 'rails', '
|
34
|
+
spec.add_runtime_dependency 'rails', '>= 4.1'
|
35
35
|
spec.add_runtime_dependency 'thor', '~> 1.0'
|
36
36
|
|
37
37
|
spec.add_development_dependency 'activerecord', '~> 6.0'
|
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.6.
|
4
|
+
version: 0.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_url
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '4.1'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '4.1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: thor
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -342,9 +342,11 @@ files:
|
|
342
342
|
- ".gitignore"
|
343
343
|
- ".rspec"
|
344
344
|
- ".rubocop.yml"
|
345
|
+
- ".ruby-version"
|
345
346
|
- ".strong_versions.yml"
|
346
347
|
- ".travis.yml"
|
347
348
|
- Gemfile
|
349
|
+
- Gemfile.lock
|
348
350
|
- LICENSE
|
349
351
|
- Makefile
|
350
352
|
- README.md
|
@@ -422,16 +424,16 @@ require_paths:
|
|
422
424
|
- lib
|
423
425
|
required_ruby_version: !ruby/object:Gem::Requirement
|
424
426
|
requirements:
|
425
|
-
- - "
|
427
|
+
- - ">="
|
426
428
|
- !ruby/object:Gem::Version
|
427
|
-
version: '2.
|
429
|
+
version: '2.6'
|
428
430
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
429
431
|
requirements:
|
430
432
|
- - ">="
|
431
433
|
- !ruby/object:Gem::Version
|
432
434
|
version: '0'
|
433
435
|
requirements: []
|
434
|
-
rubygems_version: 3.1
|
436
|
+
rubygems_version: 3.0.3.1
|
435
437
|
signing_key:
|
436
438
|
specification_version: 4
|
437
439
|
summary: Docker orchestration toolkit
|