orchestration 0.6.4 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99bdeb106830843d2a0e600151a4d80b411d21e86f25010d6c2379810ef85273
4
- data.tar.gz: 4b3828ec78541d1680d3e5749c0a2e428bed328313d17e13d3f4e0dc1bdb0e8b
3
+ metadata.gz: 7891efd1c4930036b2245fad46bc9bc78c0de97b3c2cce26ede48d5a6de34a2c
4
+ data.tar.gz: c56d7d3193fd6cafe76dc823924bcc1ba74fda288090d1424bfdce148789cb51
5
5
  SHA512:
6
- metadata.gz: 0e5a03e78c1e442daa079a5d92540df52a148b7ea08b8fa3ecd55919d045e7fc239d5638d8a850565044b9c1d7065b39c4401a72db0daef0d299c622e86ee02f
7
- data.tar.gz: e2061ef7628599f65c05d28380376ef841a329f85408c2dfa84172907ada7392dc0ba556b01a6559f3869b1f7b6809304615ebe91a9970e71adc31d04a0e82ed
6
+ metadata.gz: c82db0ac9646d8b93ad2ef72cff3216106e8558f670c086cd0647f5496559f0a0c32309b8e2680323e627345a9f6da9f2745d4d67a5a1d8d1e7a56d2fc91417c
7
+ data.tar.gz: c0fc26b8ea7f66f7a50b52de3991fe5f4a99ec73b9186312e397fce229c184f8bdf8182d8bca991a79cb5b95f24ed3ce1907048bf27dceff482437129ce18ad4
data/.strong_versions.yml CHANGED
@@ -1,2 +1,4 @@
1
1
  ignore:
2
2
  - i18n
3
+ - rails
4
+ - activerecord
data/README.md CHANGED
@@ -26,10 +26,18 @@ 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.0'
35
+ ```
36
+
37
+ _Ruby 2.x_:
30
38
 
31
39
  ```ruby
32
- gem 'orchestration', '~> 0.6.4'
40
+ gem 'orchestration', '~> 0.6.6'
33
41
  ```
34
42
 
35
43
  Install:
@@ -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
data/UPGRADE.md CHANGED
@@ -1,6 +1,18 @@
1
- # Upgrade guide
1
+ # Upgrade guide (0.5 to 0.6)
2
2
 
3
- ## 0.5 to 0.6
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.:
@@ -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
@@ -52,7 +54,7 @@ module Orchestration
52
54
  raise ArgumentError,
53
55
  I18n.t(
54
56
  'orchestration.rake.app.unspported_web_server',
55
- server: server,
57
+ server:,
56
58
  expected: %w[puma unicorn]
57
59
  )
58
60
  end
@@ -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',
@@ -42,6 +42,8 @@ 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
@@ -75,7 +77,7 @@ module Orchestration
75
77
  # '{sidecar-27018:}27017' => '27018:27017'
76
78
  local, _, remote = mapping.sub(/\${sidecar-(\d+):}/, '\1:')
77
79
  .partition(':')
78
- { local: local, remote: remote }
80
+ { local:, remote: }
79
81
  end
80
82
  end
81
83
  end
@@ -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
 
@@ -15,7 +15,7 @@ module Orchestration
15
15
  def definition
16
16
  return nil unless @config.enabled?
17
17
 
18
- { 'image' => 'library/mongo' }.merge(ports).merge(volumes)
18
+ { 'image' => 'library/mongo', 'networks' => networks }.merge(ports).merge(volumes)
19
19
  end
20
20
 
21
21
  private
@@ -13,7 +13,7 @@ module Orchestration
13
13
  def definition
14
14
  return nil unless @config.enabled?
15
15
 
16
- { 'image' => 'library/rabbitmq:management' }.merge(ports)
16
+ { 'image' => 'library/rabbitmq:management', 'networks' => networks }.merge(ports)
17
17
  end
18
18
 
19
19
  def ports
@@ -9,7 +9,7 @@ module Orchestration
9
9
  def environment
10
10
  return @environment unless @environment.nil?
11
11
 
12
- ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
12
+ ENV.fetch('RAILS_ENV', nil) || ENV.fetch('RACK_ENV', nil) || '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['DEVELOPMENT_DATABASE_URL'] || ENV['DATABASE_URL']
23
+ ENV.fetch('DEVELOPMENT_DATABASE_URL', nil) || ENV.fetch('DATABASE_URL', nil)
24
24
  when 'test'
25
- ENV['TEST_DATABASE_URL'] || ENV['DATABASE_URL']
25
+ ENV.fetch('TEST_DATABASE_URL', nil) || ENV.fetch('DATABASE_URL', nil)
26
26
  else
27
- ENV['DATABASE_URL']
27
+ ENV.fetch('DATABASE_URL', nil)
28
28
  end
29
29
  end
30
30
 
31
31
  def mongo_url
32
- ENV['MONGO_URL']
32
+ ENV.fetch('MONGO_URL', nil)
33
33
  end
34
34
 
35
35
  def mongoid_configuration_path
@@ -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: line, regex: regex)
98
+ return if line_in_file?(path, line:, regex:)
99
99
 
100
- append_file(path, "\n#{line.chomp}\n", echo: 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['force'] == 'yes'
134
+ ENV.fetch('force', nil) == 'yes'
135
135
  end
136
136
  end
137
137
  end
@@ -68,7 +68,7 @@ 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: regex)
71
+ ensure_line_in_file(gemfile_path, "gem 'unicorn'", regex:)
72
72
  end
73
73
 
74
74
  def database_yml
@@ -99,13 +99,21 @@ exit_fail=( \
99
99
  )
100
100
 
101
101
  ifdef env_file
102
- -include ${env_file}
102
+ env_path=${env_file}
103
103
  else
104
- ifneq (${env},test)
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
- rake_cmd:=${rake}
137
- rake=. ${env_file} && ${rake_cmd}
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)
@@ -214,7 +224,7 @@ start: _create-log-directory _clean-logs
214
224
  ifneq (,${compose_services})
215
225
  @$(call system,${compose_human} up --detach)
216
226
  ifeq (${env},$(filter ${env},test development))
217
- ${compose} up --detach --force-recreate --renew-anon-volumes --remove-orphans ${services} ${log} || ${exit_fail}
227
+ @${compose} up --detach --force-recreate --renew-anon-volumes --remove-orphans ${services} ${log} || ${exit_fail}
218
228
  @[ -n '${sidecar}' ] && \
219
229
  ( \
220
230
  $(call echo,(joining dependency network ${cyan}${network}${reset})) ; \
@@ -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 DATABASE_URL="${url}")
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:schema:load DATABASE_URL="${url}")
309
- @${rake} db:schema:load DATABASE_URL='${url}' ${log} || ${exit_fail}
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=${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}")
@@ -21,10 +21,10 @@ module Orchestration
21
21
  def settings(healthcheck: false)
22
22
  {
23
23
  adapter: adapter.name,
24
- host: host,
25
- port: port,
26
- username: username,
27
- password: password,
24
+ host:,
25
+ port:,
26
+ username:,
27
+ password:,
28
28
  database: healthcheck ? adapter.credentials['database'] : database
29
29
  }.transform_keys(&:to_s)
30
30
  end
@@ -64,7 +64,7 @@ module Orchestration
64
64
  return {} unless File.exist?(database_configuration_path) || custom?
65
65
 
66
66
  yaml = ERB.new(File.read(database_configuration_path)).result
67
- YAML.safe_load(yaml, [], [], true)[@env.environment] || {}
67
+ YAML.safe_load(yaml, aliases: true)[@env.environment] || {}
68
68
  end
69
69
 
70
70
  def url_config
@@ -74,7 +74,7 @@ module Orchestration
74
74
 
75
75
  def yaml(content)
76
76
  # Whitelist `Symbol` and permit aliases:
77
- YAML.safe_load(content, [Symbol], [], true)
77
+ YAML.safe_load(content, permitted_classes: [Symbol], aliases: true)
78
78
  end
79
79
  end
80
80
  end
@@ -19,7 +19,7 @@ module Orchestration
19
19
 
20
20
  def connection_error(code)
21
21
  raise HTTPConnectionError,
22
- I18n.t('orchestration.http.connection_error', code: code)
22
+ I18n.t('orchestration.http.connection_error', code:)
23
23
  end
24
24
 
25
25
  def connection_error?(code)
@@ -64,7 +64,7 @@ module Orchestration
64
64
  return {} unless File.exist?(@env.mongoid_configuration_path)
65
65
 
66
66
  yaml = File.read(@env.mongoid_configuration_path)
67
- config = YAML.safe_load(yaml, [], [], true)
67
+ config = YAML.safe_load(yaml, aliases: true)
68
68
  env = config.fetch(@env.environment, nil)
69
69
  return {} if env.nil?
70
70
 
@@ -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=abc123 bundle exec rake assets:precompile<% elsif Rake::Task.tasks.map(&:name).include?('assets:precompile') %>RUN NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=abc123 bundle exec rake assets:precompile<% end %>
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: setup
33
+ .PHONY: develop
34
34
  develop:
35
35
  bundle install
36
- @$(MAKE) start env=test
37
- @$(MAKE) start env=development
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],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.6.4'
4
+ VERSION = '0.7.0'
5
5
  end
data/lib/orchestration.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'erb'
4
4
  require 'pathname'
5
5
  require 'socket'
6
+ require 'yaml'
6
7
 
7
8
  require 'database_url'
8
9
  require 'erubis'
@@ -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
@@ -34,7 +124,7 @@ namespace :orchestration do
34
124
  desc I18n.t('orchestration.rake.db.console')
35
125
  task :console do
36
126
  env = Orchestration::Environment.new
37
- options = ENV['db'] ? { config_path: "config/database.#{ENV['db']}.yml" } : {}
127
+ options = ENV['db'] ? { config_path: "config/database.#{ENV.fetch('db', nil)}.yml" } : {}
38
128
  sh Orchestration::Services::Database::Configuration.new(env, nil, options).console_command
39
129
  end
40
130
  end
@@ -71,7 +161,7 @@ namespace :orchestration do
71
161
  end
72
162
 
73
163
  adapter::Healthcheck.start(
74
- nil, nil, config_path: path, service_name: name, sidecar: ENV['sidecar']
164
+ nil, nil, config_path: path, service_name: name, sidecar: ENV.fetch('sidecar', nil)
75
165
  )
76
166
  end
77
167
  end
@@ -22,33 +22,33 @@ Gem::Specification.new do |spec|
22
22
  end
23
23
  end
24
24
 
25
- spec.required_ruby_version = '~> 2.7'
25
+ spec.required_ruby_version = '>= 3.1'
26
26
  spec.bindir = 'bin'
27
27
  spec.executables = []
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_runtime_dependency 'database_url', '~> 0.1.2'
31
31
  spec.add_runtime_dependency 'erubis', '~> 2.7'
32
- spec.add_runtime_dependency 'i18n', '>= 0.5'
33
- spec.add_runtime_dependency 'paint', '~> 2.0'
34
- spec.add_runtime_dependency 'rails', '~> 6.0'
35
- spec.add_runtime_dependency 'thor', '~> 1.0'
32
+ spec.add_runtime_dependency 'i18n'
33
+ spec.add_runtime_dependency 'paint', '~> 2.2'
34
+ spec.add_runtime_dependency 'rails', '>= 6.1'
35
+ spec.add_runtime_dependency 'thor', '~> 1.2'
36
36
 
37
- spec.add_development_dependency 'activerecord', '~> 6.0'
38
- spec.add_development_dependency 'bunny', '~> 2.12'
39
- spec.add_development_dependency 'devpack', '~> 0.3.2'
40
- spec.add_development_dependency 'mongoid', '~> 7.0'
41
- spec.add_development_dependency 'mysql2', '~> 0.5.2'
42
- spec.add_development_dependency 'pg', '~> 1.1'
43
- spec.add_development_dependency 'rails', '~> 6.0'
44
- spec.add_development_dependency 'rake', '~> 10.0'
45
- spec.add_development_dependency 'rspec', '~> 3.0'
46
- spec.add_development_dependency 'rspec-its', '~> 1.2'
47
- spec.add_development_dependency 'rubocop', '~> 1.12'
48
- spec.add_development_dependency 'rubocop-rails', '~> 2.9'
49
- spec.add_development_dependency 'rubocop-rake', '~> 0.5.1'
50
- spec.add_development_dependency 'rubocop-rspec', '~> 2.2'
51
- spec.add_development_dependency 'sqlite3', '~> 1.3'
37
+ spec.add_development_dependency 'activerecord', '>= 6.0'
38
+ spec.add_development_dependency 'bunny', '~> 2.19'
39
+ spec.add_development_dependency 'devpack', '~> 0.4.0'
40
+ spec.add_development_dependency 'mongoid', '~> 7.4'
41
+ spec.add_development_dependency 'mysql2', '~> 0.5.3'
42
+ spec.add_development_dependency 'pg', '~> 1.3'
43
+ spec.add_development_dependency 'rails'
44
+ spec.add_development_dependency 'rake', '~> 13.0'
45
+ spec.add_development_dependency 'rspec', '~> 3.11'
46
+ spec.add_development_dependency 'rspec-its', '~> 1.3'
47
+ spec.add_development_dependency 'rubocop', '~> 1.28'
48
+ spec.add_development_dependency 'rubocop-rails', '~> 2.14'
49
+ spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
50
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.10'
51
+ spec.add_development_dependency 'sqlite3', '~> 1.4'
52
52
  spec.add_development_dependency 'strong_versions', '~> 0.4.5'
53
- spec.add_development_dependency 'webmock', '~> 3.4'
53
+ spec.add_development_dependency 'webmock', '~> 3.14'
54
54
  end
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
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2022-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: database_url
@@ -44,68 +44,68 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0.5'
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0.5'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: paint
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: '2.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: '2.2'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '6.0'
75
+ version: '6.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: '6.0'
82
+ version: '6.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: '1.2'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.0'
96
+ version: '1.2'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: activerecord
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '6.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '6.0'
111
111
  - !ruby/object:Gem::Dependency
@@ -114,196 +114,196 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '2.12'
117
+ version: '2.19'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '2.12'
124
+ version: '2.19'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: devpack
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.3.2
131
+ version: 0.4.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.3.2
138
+ version: 0.4.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: mongoid
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '7.0'
145
+ version: '7.4'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '7.0'
152
+ version: '7.4'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mysql2
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 0.5.2
159
+ version: 0.5.3
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 0.5.2
166
+ version: 0.5.3
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: pg
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: '1.1'
173
+ version: '1.3'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: '1.1'
180
+ version: '1.3'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: rails
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - "~>"
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: '6.0'
187
+ version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - "~>"
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: '6.0'
194
+ version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: rake
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '10.0'
201
+ version: '13.0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '10.0'
208
+ version: '13.0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rspec
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '3.0'
215
+ version: '3.11'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
- version: '3.0'
222
+ version: '3.11'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: rspec-its
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '1.2'
229
+ version: '1.3'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
- version: '1.2'
236
+ version: '1.3'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: rubocop
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
- version: '1.12'
243
+ version: '1.28'
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
- version: '1.12'
250
+ version: '1.28'
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: rubocop-rails
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
255
  - - "~>"
256
256
  - !ruby/object:Gem::Version
257
- version: '2.9'
257
+ version: '2.14'
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
- version: '2.9'
264
+ version: '2.14'
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: rubocop-rake
267
267
  requirement: !ruby/object:Gem::Requirement
268
268
  requirements:
269
269
  - - "~>"
270
270
  - !ruby/object:Gem::Version
271
- version: 0.5.1
271
+ version: 0.6.0
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - "~>"
277
277
  - !ruby/object:Gem::Version
278
- version: 0.5.1
278
+ version: 0.6.0
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: rubocop-rspec
281
281
  requirement: !ruby/object:Gem::Requirement
282
282
  requirements:
283
283
  - - "~>"
284
284
  - !ruby/object:Gem::Version
285
- version: '2.2'
285
+ version: '2.10'
286
286
  type: :development
287
287
  prerelease: false
288
288
  version_requirements: !ruby/object:Gem::Requirement
289
289
  requirements:
290
290
  - - "~>"
291
291
  - !ruby/object:Gem::Version
292
- version: '2.2'
292
+ version: '2.10'
293
293
  - !ruby/object:Gem::Dependency
294
294
  name: sqlite3
295
295
  requirement: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - "~>"
298
298
  - !ruby/object:Gem::Version
299
- version: '1.3'
299
+ version: '1.4'
300
300
  type: :development
301
301
  prerelease: false
302
302
  version_requirements: !ruby/object:Gem::Requirement
303
303
  requirements:
304
304
  - - "~>"
305
305
  - !ruby/object:Gem::Version
306
- version: '1.3'
306
+ version: '1.4'
307
307
  - !ruby/object:Gem::Dependency
308
308
  name: strong_versions
309
309
  requirement: !ruby/object:Gem::Requirement
@@ -324,14 +324,14 @@ dependencies:
324
324
  requirements:
325
325
  - - "~>"
326
326
  - !ruby/object:Gem::Version
327
- version: '3.4'
327
+ version: '3.14'
328
328
  type: :development
329
329
  prerelease: false
330
330
  version_requirements: !ruby/object:Gem::Requirement
331
331
  requirements:
332
332
  - - "~>"
333
333
  - !ruby/object:Gem::Version
334
- version: '3.4'
334
+ version: '3.14'
335
335
  description: Tools to help launch apps in Docker
336
336
  email:
337
337
  - git@bob.frl
@@ -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.7'
427
+ version: '3.1'
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.6
434
+ rubygems_version: 3.3.7
435
435
  signing_key:
436
436
  specification_version: 4
437
437
  summary: Docker orchestration toolkit