orchestration 0.5.4 → 0.5.5

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: f0bd959d8a5186a473d26fe78039a6aaf752e8601136c77d3cc67611ee9e2a7c
4
- data.tar.gz: 827da8b5d32566d8c15a3949de5671f06b61a63f41a818b22186d13076e99e34
3
+ metadata.gz: e312ede29eb601b4e9413df1b711881997f81629b6f208c0ea7e62102d4a6b44
4
+ data.tar.gz: 4483fd3532b1bf27bb9a6b76e38c996a02f046164ed23ce85d5df5720e933ff3
5
5
  SHA512:
6
- metadata.gz: 65927e812ffa3dde5cefadfd458ce02bfc912263977a85634ef84170d727b61a97e955b817e1b0139238d669d5c622d06ac680ee410da4035bd9ec75d5db1e5c
7
- data.tar.gz: d9e6fe7c2b46d601149cf6442953abaa5c3cba737ec7bbe9054f6779a57ad4a7b49c59b290a89d1610e4774b3aa6dc452b2aa5f09e5132cd6826f96a95122f5d
6
+ metadata.gz: 6539ea72eabd6683691749179cb4bd08c9f9e3f334ced7348236058a2926a6e25f6a09176c47efb1f40a0b22f57f96c9d1fb9ba4274c25036a4cd03e3d3f6ead
7
+ data.tar.gz: caed0598c1dc565457e0437943a0c031b78c3bef1ab99d5ae313368af6a4e0a84e7451bc46560e454457a5fa5c8e83c5ff6019fc114c3fd22e0a0dfac00d9c61
data/README.md CHANGED
@@ -27,7 +27,7 @@ The below screenshot demonstrates _Orchestration_ being installed in a brand new
27
27
  Add _Orchestration_ to your Gemfile:
28
28
 
29
29
  ```ruby
30
- gem 'orchestration', '~> 0.5.4'
30
+ gem 'orchestration', '~> 0.5.5'
31
31
  ```
32
32
 
33
33
  Install:
@@ -227,6 +227,8 @@ To connect via _SSH_ to a remote swarm and deploy, pass the `manager` parameter:
227
227
  make deploy manager=user@manager.swarm.example.com
228
228
  ```
229
229
 
230
+ The file `orchestration/docker-compose.production.yml` is created automatically. If your `RAILS_ENV` is set to something other than `production` then another file will need to be created (e.g. `orchestration/docker-compose.staging.yml`). In most cases this file can be a _symlink_ to the original `production` configuration and environment variables can be used to customise the content.
231
+
230
232
  #### Roll back a deployment
231
233
 
232
234
  Roll back the `app` service of your stack:
@@ -270,7 +272,7 @@ Note that the following two variables _must_ be set in the relevant `.env` file
270
272
 
271
273
  ```
272
274
  # Published port for your application service:
273
- CONTAINER_PORT=3000
275
+ PUBLISH_PORT=3000
274
276
 
275
277
  # Number of replicas of your application service:
276
278
  REPLICAS=5
@@ -325,7 +327,7 @@ See related documentation:
325
327
  | `WEB_HEALTHCHECK_PATH` | Path expected to return a successful response | `/` |
326
328
  | `WEB_HEALTHCHECK_READ_TIMEOUT` | Number of seconds to wait for data before failing healthcheck | `10` |
327
329
  | `WEB_HEALTHCHECK_OPEN_TIMEOUT` | Number of seconds to wait for connection before failing healthcheck | `10` |
328
- | `WEB_HEALTHCHECK_SUCCESS_CODES` | Comma-separated list of HTTP status codes that will be deemed a success | `200,202,204` |
330
+ | `WEB_HEALTHCHECK_SUCCESS_CODES` | Comma-separated list of HTTP status codes that will be deemed a success | `200,201,202,204` |
329
331
 
330
332
  If your application does not have a suitable always-available route to use as a healthcheck, the following one-liner may be useful:
331
333
 
@@ -11,7 +11,7 @@ require 'paint'
11
11
  begin
12
12
  require 'rails'
13
13
  rescue LoadError
14
- warn('[orchestration] Rails not detected; skipping.')
14
+ warn('[orchestration] Running in non-Rails mode.')
15
15
  end
16
16
 
17
17
  I18n.load_path += Dir[File.join(File.expand_path('..', __dir__),
@@ -113,7 +113,7 @@ module Orchestration
113
113
  end
114
114
 
115
115
  def ports
116
- ['${CONTAINER_PORT:?CONTAINER_PORT must be provided}:8080']
116
+ ['${PUBLISH_PORT:?PUBLISH_PORT must be provided}:8080']
117
117
  end
118
118
  end
119
119
  end
@@ -40,7 +40,7 @@ module Orchestration
40
40
  end
41
41
 
42
42
  def success_codes
43
- ENV.fetch('WEB_HEALTHCHECK_SUCCESS_CODES', '200,202,204').split(',')
43
+ ENV.fetch('WEB_HEALTHCHECK_SUCCESS_CODES', '200,201,202,204').split(',')
44
44
  end
45
45
 
46
46
  def success?(code)
@@ -82,7 +82,7 @@ module Orchestration
82
82
  end
83
83
 
84
84
  def app_port
85
- ENV.fetch('CONTAINER_PORT', ENV.fetch('WEB_PORT', '3000')).to_i
85
+ ENV.fetch('PUBLISH_PORT', ENV.fetch('WEB_PORT', '3000')).to_i
86
86
  end
87
87
 
88
88
  def app_name
@@ -18,9 +18,11 @@ module Orchestration
18
18
  def run
19
19
  return unless @service.configuration.configured?
20
20
 
21
+ @service.modify_environment
21
22
  echo_start
22
23
  success = attempt_connection
23
24
  echo_ready if success
25
+ @service.unmodify_environment
24
26
  success
25
27
  end
26
28
 
@@ -19,6 +19,18 @@ module Orchestration
19
19
  [ActiveRecord::ConnectionNotEstablished].concat(adapter_errors)
20
20
  end
21
21
 
22
+ def modify_environment
23
+ @database_url = ENV.delete('DATABASE_URL')
24
+ @development_database_url = ENV.delete('DEVELOPMENT_DATABASE_URL')
25
+ @test_database_url = ENV.delete('TEST_DATABASE_URL')
26
+ end
27
+
28
+ def unmodify_environment
29
+ ENV['DATABASE_URL'] = @database_url
30
+ ENV['DEVELOPMENT_DATABASE_URL'] = @development_database_url
31
+ ENV['TEST_DATABASE_URL'] = @test_database_url
32
+ end
33
+
22
34
  private
23
35
 
24
36
  def adapter_errors
@@ -26,6 +26,10 @@ module Orchestration
26
26
  @dependencies = args
27
27
  end
28
28
 
29
+ def modify_environment; end
30
+
31
+ def unmodify_environment; end
32
+
29
33
  private
30
34
 
31
35
  def load_dependencies
@@ -15,8 +15,10 @@ test: test-setup
15
15
 
16
16
  # Start development containers and create/migrate/seed database
17
17
  .PHONY: develop
18
- develop: start
18
+ develop:
19
19
  bundle install
20
+ @$(MAKE) start env=test
21
+ @$(MAKE) start env=development
20
22
  bundle exec rake db:create
21
23
  bundle exec rake db:migrate
22
24
  bundle exec rake db:seed
@@ -8,8 +8,8 @@ else ifneq (,$(RACK_ENV))
8
8
  endif
9
9
 
10
10
  verify-environment:
11
- ifndef CONTAINER_PORT
12
- @$(error `CONTAINER_PORT` must be defined in environment)
11
+ ifndef PUBLISH_PORT
12
+ @$(error `PUBLISH_PORT` must be defined in environment)
13
13
  endif
14
14
 
15
15
  ifndef env
@@ -114,7 +114,7 @@ all: build
114
114
  ifndef network
115
115
  start: network := ${compose_project_name}_default
116
116
  endif
117
- start: _clean-logs
117
+ start: _create-log-directory _clean-logs
118
118
  @$(call print,'${yellow}Starting ${cyan}${env}${yellow} containers${reset} ...')
119
119
  ifeq (${env},$(filter ${env},test development))
120
120
  @${compose} up --detach --force-recreate --renew-anon-volumes --remove-orphans ${services} ${log} || ${fail}
@@ -276,7 +276,7 @@ deploy:
276
276
  ifndef manager
277
277
  @$(call println_error,'Missing `manager` parameter: `make deploy manager=swarm-manager.example.com`') ; exit 1
278
278
  endif
279
- @$(call println,'${yellow}Deploying stack via${reset} ${green}${manager}${reset} ...') && \
279
+ @$(call println,'${yellow}Deploying ${green}${env}${reset} stack via${reset} ${green}${manager}${reset} ...') && \
280
280
  ( \
281
281
  $(call make,bundle path='${path}/bundle.tar') ${log} && \
282
282
  cd '${path}' ${log} && \
@@ -326,7 +326,7 @@ wait-listener:
326
326
  .PHONY: build
327
327
  build: build_dir = ${orchestration_dir}/.build
328
328
  build: context = ${build_dir}/context.tar
329
- build: check-local-changes
329
+ build: _create-log-directory check-local-changes
330
330
  @$(call print,'${yellow}Preparing build context from${reset} ${cyan}${git_branch}:${git_version}${reset} ... ')
331
331
  @mkdir -p ${orchestration_dir}/.build ${log} || ${fail}
332
332
  ifndef dev
@@ -367,7 +367,7 @@ endif
367
367
  @$(call println,'[${green}tag${reset}] ${cyan}${docker_organization}/${docker_repository}:${git_version}${reset}')
368
368
 
369
369
  .PHONY: push
370
- push:
370
+ push: _create-log-directory
371
371
  @$(call print,'${yellow}Pushing${reset} ${cyan}${docker_image}${reset} ...')
372
372
  @docker push ${docker_image} ${log_progress} || ${fail}
373
373
  @$(call printrawln,' ${green}complete${reset}. ${tick}')
@@ -389,3 +389,7 @@ endif
389
389
  _clean-logs:
390
390
  @rm -f '${stdout}' '${stderr}'
391
391
  @touch '${stdout}' '${stderr}'
392
+
393
+ .PHONY: _create-log-directory
394
+ _create-log-directory:
395
+ @mkdir -p log
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchestration
4
- VERSION = '0.5.4'
4
+ VERSION = '0.5.5'
5
5
  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.5.4
4
+ version: 0.5.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: 2020-07-05 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: database_url
@@ -322,10 +322,7 @@ files:
322
322
  - README.md
323
323
  - Rakefile
324
324
  - bin/console
325
- - bin/rspec
326
- - bin/rubocop
327
325
  - bin/setup
328
- - bin/strong_versions
329
326
  - config/locales/en.yml
330
327
  - doc/images/example.png
331
328
  - lib/Rakefile
data/bin/rspec DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rspec' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rspec-core", "rspec")
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rubocop' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rubocop", "rubocop")
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'strong_versions' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("strong_versions", "strong_versions")