orchestration 0.6.2 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/locales/en.yml +1 -0
- data/lib/orchestration/docker_compose/app_service.rb +5 -7
- data/lib/orchestration/docker_compose/compose_configuration.rb +4 -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 +8 -4
- data/lib/orchestration/make/orchestration.mk +12 -5
- data/lib/orchestration/templates/application.mk.erb +3 -6
- data/lib/orchestration/version.rb +1 -1
- data/lib/tasks/orchestration.rake +6 -0
- data/orchestration.gemspec +2 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22c01beaeb79e418062c87c7d0d8d9fdc472cc479c16a47d9be01ca0278abc04
|
4
|
+
data.tar.gz: 78ad03978e9fcdb0ebf9cf1a02af1395dc356cdf5dac048eb06ab741396f4166
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94d8bdc996d37ae9b51bfd3a44f945e0f30b466d3bebb753b535c9e63558962d0661905fd4690677e946789bef76d9276f7047c4c990e7d9cfe6518b584e752f
|
7
|
+
data.tar.gz: 9f785e2f76dac85f01c36db3fbc3d24724e52e4f36aaffe95f388e782b98b0d6f351b173383a42950405b3fe427901c4ba49c5a6e64d61f0b88c385e0a581393
|
data/README.md
CHANGED
data/config/locales/en.yml
CHANGED
@@ -29,6 +29,7 @@ en:
|
|
29
29
|
rake:
|
30
30
|
config: "Parse and output Orchestration config (internal use)"
|
31
31
|
healthcheck: "Execute healthcheck; used for HEALTHCHECK command in Docker image"
|
32
|
+
compose_services: "Output configured services for a given environment (RAILS_ENV)"
|
32
33
|
install: "Install Orchestration tools"
|
33
34
|
install_makefile: "(Re)create orchestration/Makefile"
|
34
35
|
wait: "Wait for development/test dependencies to be available"
|
@@ -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,19 +91,15 @@ 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',
|
99
97
|
'RAILS_SERVE_STATIC_FILES' => '1',
|
100
98
|
'WEB_PRELOAD_APP' => '1',
|
101
|
-
'WEB_HEALTHCHECK_PATH' => '/',
|
99
|
+
'WEB_HEALTHCHECK_PATH' => '/healthcheck',
|
102
100
|
'WEB_PORT' => 8080,
|
103
101
|
'DATABASE_URL' => database_url
|
104
|
-
}.merge(inherited_environment.
|
102
|
+
}.merge(inherited_environment.to_h { |key| [key, nil] }).merge(rabbitmq_urls)
|
105
103
|
end
|
106
104
|
|
107
105
|
def rabbitmq_urls
|
@@ -115,7 +113,7 @@ module Orchestration
|
|
115
113
|
'postgresql' => 'postgresql://postgres:password@database-local:5432/production',
|
116
114
|
'mysql2' => 'mysql2://root:password@database-local:3306/production',
|
117
115
|
'sqlite3' => 'sqlite3:db/production.sqlite3'
|
118
|
-
}.fetch(DockerCompose::ComposeConfiguration.database_adapter_name)
|
116
|
+
}.fetch(DockerCompose::ComposeConfiguration.database_adapter_name, nil)
|
119
117
|
end
|
120
118
|
|
121
119
|
def inherited_environment
|
@@ -42,12 +42,16 @@ module Orchestration
|
|
42
42
|
ports(name).find { |mapping| mapping[:remote] == remote_port }
|
43
43
|
.fetch(:local)
|
44
44
|
.to_i
|
45
|
+
rescue NoMethodError
|
46
|
+
nil
|
45
47
|
end
|
46
48
|
|
47
49
|
private
|
48
50
|
|
49
51
|
def config
|
50
52
|
@config ||= @env.docker_compose_config
|
53
|
+
rescue Errno::ENOENT
|
54
|
+
{}
|
51
55
|
end
|
52
56
|
|
53
57
|
def listener?(name)
|
@@ -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
|
|
@@ -69,12 +69,12 @@ module Orchestration
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def default_app_name
|
72
|
-
default = docker_filter(root.basename.to_s)
|
72
|
+
default = docker_filter(root.basename.to_s, underscore: true)
|
73
73
|
return default unless defined?(Rails)
|
74
74
|
# Edge case if Rails is used as a dependency but we are not a Rails app:
|
75
75
|
return default if rails_application == Object
|
76
76
|
|
77
|
-
docker_filter(rails_application.name.underscore)
|
77
|
+
docker_filter(rails_application.name.underscore, underscore: true)
|
78
78
|
end
|
79
79
|
|
80
80
|
def rabbitmq_url
|
@@ -126,10 +126,14 @@ module Orchestration
|
|
126
126
|
app_class.parent
|
127
127
|
end
|
128
128
|
|
129
|
-
def docker_filter(string)
|
129
|
+
def docker_filter(string, underscore: false)
|
130
130
|
# Filter out characters not accepted by Docker Hub
|
131
131
|
permitted = [('0'..'9'), ('a'..'z')].map(&:to_a).flatten
|
132
|
-
string.chars.select
|
132
|
+
string.chars.select do |char|
|
133
|
+
next true if underscore && char == '_'
|
134
|
+
|
135
|
+
permitted.include?(char)
|
136
|
+
end.join
|
133
137
|
end
|
134
138
|
end
|
135
139
|
end
|
@@ -141,6 +141,8 @@ docker_config:=$(shell DEVPACK_DISABLE=1 RAILS_ENV=development ${bundle_cmd} rak
|
|
141
141
|
docker_organization=$(word 1,$(docker_config))
|
142
142
|
docker_repository=$(word 2,$(docker_config))
|
143
143
|
|
144
|
+
compose_services:=$(shell ${rake} orchestration:compose_services RAILS_ENV=${env})
|
145
|
+
|
144
146
|
ifeq (,$(project_name))
|
145
147
|
project_base = ${docker_repository}_${env}
|
146
148
|
else
|
@@ -209,6 +211,7 @@ ifndef network
|
|
209
211
|
start: network := ${compose_project_name}
|
210
212
|
endif
|
211
213
|
start: _create-log-directory _clean-logs
|
214
|
+
ifneq (,${compose_services})
|
212
215
|
@$(call system,${compose_human} up --detach)
|
213
216
|
ifeq (${env},$(filter ${env},test development))
|
214
217
|
@${compose} up --detach --force-recreate --renew-anon-volumes --remove-orphans ${services} ${log} || ${exit_fail}
|
@@ -229,10 +232,12 @@ endif
|
|
229
232
|
@$(call echo,${env_human} containers started ${tick})
|
230
233
|
@$(call echo,Waiting for services to become available)
|
231
234
|
@$(call make,wait) 2>${stderr} || ${exit_fail}
|
235
|
+
endif
|
232
236
|
|
233
237
|
.PHONY: stop
|
234
238
|
stop: network := ${compose_project_name}
|
235
239
|
stop:
|
240
|
+
ifneq (,${compose_services})
|
236
241
|
@$(call echo,Stopping ${env_human} containers)
|
237
242
|
@$(call system,${compose_human} down)
|
238
243
|
@if docker ps --format "{{.ID}}" | grep -q $(shell hostname) ; \
|
@@ -244,6 +249,7 @@ stop:
|
|
244
249
|
${compose} down ${log} || ${exit_fail} ; \
|
245
250
|
fi
|
246
251
|
@$(call echo,${env_human} containers stopped ${tick})
|
252
|
+
endif
|
247
253
|
|
248
254
|
.PHONY: logs
|
249
255
|
logs:
|
@@ -288,7 +294,9 @@ db-console:
|
|
288
294
|
@${rake} orchestration:db:console RAILS_ENV=${env}
|
289
295
|
|
290
296
|
.PHONY: setup
|
297
|
+
ifneq (,$(wildcard config/database.yml))
|
291
298
|
setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env})
|
299
|
+
endif
|
292
300
|
setup: _log-notify
|
293
301
|
@$(call echo,Setting up ${env_human} environment)
|
294
302
|
@$(call make,start env=${env})
|
@@ -306,9 +314,9 @@ ifneq (,$(wildcard config/database.yml))
|
|
306
314
|
@$(call system,rake db:migrate DATABASE_URL="${url}")
|
307
315
|
@${rake} db:migrate RAILS_ENV=${env}
|
308
316
|
endif
|
309
|
-
|
310
|
-
|
311
|
-
&& $(MAKE) post-setup RAILS_ENV=${env}
|
317
|
+
@if $(MAKE) -n post-setup >/dev/null 2>&1; then \
|
318
|
+
$(call system,make post-setup RAILS_ENV=${env}) \
|
319
|
+
&& $(MAKE) post-setup RAILS_ENV=${env}; fi
|
312
320
|
@$(call echo,${env_human} environment setup complete ${tick})
|
313
321
|
|
314
322
|
.PHONY: dump
|
@@ -437,12 +445,11 @@ endif
|
|
437
445
|
ifdef include
|
438
446
|
@$(call echo,Including files from: ${cyan}${include}${reset})
|
439
447
|
@(while read line; do \
|
440
|
-
_system "echo '${system_prefix}' $$1 }"; \
|
441
448
|
export line; \
|
442
449
|
include_dir="${build_dir}/$$(dirname "$${line}")/" && \
|
443
450
|
mkdir -p "$${include_dir}" && cp "$${line}" "$${include_dir}" \
|
444
451
|
&& (cd '${orchestration_dir}/.build/' && tar rf 'context.tar' "$${line}"); \
|
445
|
-
|
452
|
+
echo "${system_prefix}" "tar rf 'context.tar' '$${line}'"; \
|
446
453
|
done < '${include}') ${log} || ${exit_fail}
|
447
454
|
@$(call echo,Build context ${green}ready${reset} ${tick})
|
448
455
|
endif
|
@@ -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
|
@@ -39,6 +39,12 @@ namespace :orchestration do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
desc I18n.t('orchestration.rake.compose_services')
|
43
|
+
task :compose_services do
|
44
|
+
config = Orchestration::DockerCompose::ComposeConfiguration.new(Orchestration::Environment.new)
|
45
|
+
puts config.services.keys.join(' ') unless config.services.nil? || config.services.empty?
|
46
|
+
end
|
47
|
+
|
42
48
|
desc I18n.t('orchestration.rake.healthcheck')
|
43
49
|
task :healthcheck do
|
44
50
|
Orchestration::DockerHealthcheck.execute
|
data/orchestration.gemspec
CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.summary = 'Docker orchestration toolkit'
|
15
15
|
spec.description = 'Tools to help launch apps in Docker'
|
16
16
|
spec.homepage = url
|
17
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
17
18
|
|
18
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
20
|
`git ls-files -z`.split("\x0").reject do |f|
|
@@ -21,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
spec.required_ruby_version = '~> 2.
|
25
|
+
spec.required_ruby_version = '~> 2.7'
|
25
26
|
spec.bindir = 'bin'
|
26
27
|
spec.executables = []
|
27
28
|
spec.require_paths = ['lib']
|
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.5
|
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-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_url
|
@@ -414,7 +414,8 @@ files:
|
|
414
414
|
- orchestration.gemspec
|
415
415
|
homepage: https://github.com/bobf/orchestration
|
416
416
|
licenses: []
|
417
|
-
metadata:
|
417
|
+
metadata:
|
418
|
+
rubygems_mfa_required: 'true'
|
418
419
|
post_install_message:
|
419
420
|
rdoc_options: []
|
420
421
|
require_paths:
|
@@ -423,14 +424,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
423
424
|
requirements:
|
424
425
|
- - "~>"
|
425
426
|
- !ruby/object:Gem::Version
|
426
|
-
version: '2.
|
427
|
+
version: '2.7'
|
427
428
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
428
429
|
requirements:
|
429
430
|
- - ">="
|
430
431
|
- !ruby/object:Gem::Version
|
431
432
|
version: '0'
|
432
433
|
requirements: []
|
433
|
-
rubygems_version: 3.
|
434
|
+
rubygems_version: 3.1.6
|
434
435
|
signing_key:
|
435
436
|
specification_version: 4
|
436
437
|
summary: Docker orchestration toolkit
|