orchestration 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.strong_versions.yml +1 -0
- data/README.md +1 -1
- data/UPGRADE.md +22 -2
- data/config/locales/en.yml +1 -0
- data/lib/orchestration/make/orchestration.mk +27 -23
- data/lib/orchestration/templates/Dockerfile.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 +91 -1
- data/orchestration.gemspec +2 -2
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12b69a813bf576761bf0c72198b9bf68a9e1ce212d4dd1f1c819f50c2b3a46cf
|
4
|
+
data.tar.gz: '0383c1b95a84b29fe78ab766ed6fb8f862f32f8cd33a1695b815ecb752f00be5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b1df8619845cdf6383360e22b051f0307665b9c7137d2e2a105595cbc9ba38b39745b9c44169c3585edabc389dab18ec61f8371e73b1899c84e6a8f2c212bc3
|
7
|
+
data.tar.gz: 2d467b15257d2ce8346e9f6e9efdebbb7e23d25aed0576b205c5ec9da85dc038b81fd8d92d6dfd35cf0fbe6358aab92ef71fef94071009a941a95220741aaab7
|
data/.strong_versions.yml
CHANGED
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"
|
@@ -99,13 +99,21 @@ 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
|
+
-include ${env_path}
|
111
|
+
endif
|
112
|
+
endif
|
108
113
|
endif
|
114
|
+
|
115
|
+
ifneq (,$(findstring deploy,$(MAKECMDGOALS)))
|
116
|
+
RAILS_ENV=$(shell grep '^RAILS_ENV=' '${env_path}' | tail -n1 | sed 's/^RAILS_ENV=//')
|
109
117
|
endif
|
110
118
|
|
111
119
|
export
|
@@ -130,11 +138,13 @@ DOCKER_TAG ?= latest
|
|
130
138
|
ifneq (,$(wildcard ./Gemfile))
|
131
139
|
bundle_cmd = bundle exec
|
132
140
|
endif
|
133
|
-
rake=DEVPACK_DISABLE=1 RACK_ENV=${env} RAILS_ENV=${env} ${bundle_cmd} rake
|
141
|
+
rake=DEVPACK_DISABLE=1 RACK_ENV=${env} SECRET_KEY_BASE='placeholder-secret' RAILS_ENV=${env} ${bundle_cmd} rake
|
134
142
|
|
135
143
|
ifneq (,$(wildcard ${env_file}))
|
136
|
-
|
137
|
-
|
144
|
+
ifeq (,$(findstring deploy,$(MAKECMDGOALS)))
|
145
|
+
rake_cmd:=${rake}
|
146
|
+
rake=. ${env_file} && ${rake_cmd}
|
147
|
+
endif
|
138
148
|
endif
|
139
149
|
|
140
150
|
docker_config:=$(shell DEVPACK_DISABLE=1 RAILS_ENV=development ${bundle_cmd} rake orchestration:config 2>/dev/null || echo no-org no-repo)
|
@@ -295,27 +305,27 @@ db-console:
|
|
295
305
|
|
296
306
|
.PHONY: setup
|
297
307
|
ifneq (,$(wildcard config/database.yml))
|
298
|
-
setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env})
|
308
|
+
setup: url = $(shell ${rake} orchestration:db:url RAILS_ENV=${env} 2>/dev/null)
|
299
309
|
endif
|
300
310
|
setup: _log-notify
|
301
311
|
@$(call echo,Setting up ${env_human} environment)
|
302
312
|
@$(call make,start env=${env})
|
303
313
|
ifneq (,$(wildcard config/database.yml))
|
304
314
|
@$(call echo,Preparing ${env_human} database)
|
305
|
-
@$(call system,rake db:create
|
315
|
+
@$(call system,rake db:create RAILS_ENV="${env}")
|
306
316
|
@${rake} db:create RAILS_ENV=${env} ${log} || : ${log}
|
307
317
|
ifneq (,$(wildcard db/structure.sql))
|
308
|
-
@$(call system,rake db:
|
309
|
-
@${rake} db:
|
318
|
+
@$(call system,rake db:structure:load RAILS_ENV="${env}" DATABASE_URL="${url}")
|
319
|
+
@${rake} db:structure:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
310
320
|
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}
|
321
|
+
@$(call system,rake db:schema:load RAILS_ENV="${env}" DATABASE_URL="${url}")
|
322
|
+
@${rake} db:schema:load RAILS_ENV="${env}" DATABASE_URL='${url}' ${log} || ${exit_fail}
|
313
323
|
endif
|
314
|
-
@$(call system,rake db:migrate DATABASE_URL="${url}")
|
315
|
-
@${rake} db:migrate RAILS_ENV=${env}
|
324
|
+
@$(call system,rake db:migrate RAILS_ENV="${env}" DATABASE_URL="${url}")
|
325
|
+
@${rake} db:migrate RAILS_ENV=${env} ${log} || ${exit_fail}
|
316
326
|
endif
|
317
327
|
@if $(MAKE) -n post-setup >/dev/null 2>&1; then \
|
318
|
-
$(call system,make post-setup RAILS_ENV
|
328
|
+
$(call system,make post-setup RAILS_ENV="${env}") \
|
319
329
|
&& $(MAKE) post-setup RAILS_ENV=${env}; fi
|
320
330
|
@$(call echo,${env_human} environment setup complete ${tick})
|
321
331
|
|
@@ -422,15 +432,9 @@ wait-listener:
|
|
422
432
|
build: _log-notify _clean-logs
|
423
433
|
build: build_dir = ${orchestration_dir}/.build
|
424
434
|
build: context = ${build_dir}/context.tar
|
425
|
-
build: build_args := --build-arg GIT_COMMIT='${git_version}'
|
435
|
+
build: build_args := --build-arg GIT_COMMIT='${git_version}' $(shell grep '^ARG ' orchestration/Dockerfile | sed -e 's/=.*$$//' -e 's/^ARG /--build-arg /')
|
426
436
|
build: tag_human = ${cyan}${docker_organization}/${docker_repository}:${git_version}${reset}
|
427
437
|
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
438
|
build: _create-log-directory check-local-changes
|
435
439
|
@$(call echo,Preparing build context from ${cyan}${git_branch}${reset} (${cyan}${git_version}${reset})${reset})
|
436
440
|
@$(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'] %> \
|
@@ -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,103 @@ 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
|
-
config = Rails.application.config_for(:database)
|
113
|
+
config = Rails.application.config_for(:database).transform_keys(&:to_sym)
|
26
114
|
|
27
115
|
if config[:adapter] == 'sqlite3'
|
28
116
|
puts "sqlite3:#{config[:database]}"
|
117
|
+
elsif !config[:url].nil?
|
118
|
+
puts config[:url]
|
29
119
|
else
|
30
120
|
puts DatabaseUrl.to_active_record_url(config)
|
31
121
|
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.6
|
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-04-17 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
|
@@ -422,16 +422,16 @@ require_paths:
|
|
422
422
|
- lib
|
423
423
|
required_ruby_version: !ruby/object:Gem::Requirement
|
424
424
|
requirements:
|
425
|
-
- - "
|
425
|
+
- - ">="
|
426
426
|
- !ruby/object:Gem::Version
|
427
|
-
version: '2.
|
427
|
+
version: '2.6'
|
428
428
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
429
429
|
requirements:
|
430
430
|
- - ">="
|
431
431
|
- !ruby/object:Gem::Version
|
432
432
|
version: '0'
|
433
433
|
requirements: []
|
434
|
-
rubygems_version: 3.1
|
434
|
+
rubygems_version: 3.0.3.1
|
435
435
|
signing_key:
|
436
436
|
specification_version: 4
|
437
437
|
summary: Docker orchestration toolkit
|