indocker 0.0.6 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +10 -2
  3. data/.rspec +2 -0
  4. data/.travis.yml +7 -0
  5. data/Gemfile +5 -2
  6. data/Gemfile.lock +19 -49
  7. data/LICENSE.txt +17 -18
  8. data/README.md +20 -1
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/example/indocker/bin/deploy +120 -0
  13. data/example/indocker/bin/remote/compile +72 -0
  14. data/example/indocker/bin/remote/run +66 -0
  15. data/example/indocker/bin/utils/configurations.rb +3 -0
  16. data/example/indocker/bounded_contexts/shared/ruby/Dockerfile +10 -0
  17. data/example/indocker/bounded_contexts/shared/ruby/container.rb +5 -0
  18. data/example/indocker/bounded_contexts/shared/ruby/image.rb +3 -0
  19. data/example/indocker/configurations/dev.rb +9 -0
  20. data/example/indocker/infrastructure/build_servers.rb +8 -0
  21. data/example/indocker/infrastructure/networks.rb +1 -0
  22. data/example/indocker/infrastructure/registries.rb +3 -0
  23. data/example/indocker/infrastructure/servers.rb +8 -0
  24. data/example/indocker/setup.rb +24 -0
  25. data/indocker.gemspec +27 -25
  26. data/lib/indocker.rb +437 -130
  27. data/lib/indocker/artifacts/git.rb +25 -0
  28. data/lib/indocker/build_context.rb +87 -0
  29. data/lib/indocker/build_context_helper.rb +109 -0
  30. data/lib/indocker/build_context_pool.rb +36 -0
  31. data/lib/indocker/build_server.rb +2 -0
  32. data/lib/indocker/colored_string.rb +33 -0
  33. data/lib/indocker/concerns/inspectable.rb +12 -0
  34. data/lib/indocker/configuration_deployer.rb +525 -0
  35. data/lib/indocker/configurations/configuration.rb +122 -0
  36. data/lib/indocker/configurations/configuration_builder.rb +250 -0
  37. data/lib/indocker/configurations/formatters/stdout.rb +36 -0
  38. data/lib/indocker/container_deployer.rb +73 -0
  39. data/lib/indocker/container_helper.rb +13 -0
  40. data/lib/indocker/container_runner.rb +23 -0
  41. data/lib/indocker/containers/container.rb +118 -0
  42. data/lib/indocker/containers/container_builder.rb +186 -0
  43. data/lib/indocker/containers/restart_policy.rb +36 -0
  44. data/lib/indocker/context_args.rb +43 -0
  45. data/lib/indocker/crontab_redeploy_rules_builder.rb +54 -0
  46. data/lib/indocker/deploy_context.rb +126 -0
  47. data/lib/indocker/deployment_checker.rb +121 -0
  48. data/lib/indocker/deployment_progress.rb +495 -0
  49. data/lib/indocker/docker.rb +87 -0
  50. data/lib/indocker/docker_run_args.rb +183 -0
  51. data/lib/indocker/env_file_helper.rb +13 -0
  52. data/lib/indocker/env_files/local.rb +8 -0
  53. data/lib/indocker/env_files/remote.rb +8 -0
  54. data/lib/indocker/hash_merger.rb +9 -0
  55. data/lib/indocker/images/image.rb +86 -0
  56. data/lib/indocker/images/image_builder.rb +98 -0
  57. data/lib/indocker/images/image_compiler.rb +68 -0
  58. data/lib/indocker/images/template_compiler.rb +15 -0
  59. data/lib/indocker/images/templates_compiler.rb +28 -0
  60. data/lib/indocker/images_compiler.rb +38 -0
  61. data/lib/indocker/indocker_helper.rb +9 -0
  62. data/lib/indocker/network.rb +12 -0
  63. data/lib/indocker/network_helper.rb +7 -0
  64. data/lib/indocker/registries/abstract.rb +17 -0
  65. data/lib/indocker/registries/local.rb +5 -0
  66. data/lib/indocker/registries/remote.rb +12 -0
  67. data/lib/indocker/repositories/abstract.rb +25 -0
  68. data/lib/indocker/repositories/clonner.rb +17 -0
  69. data/lib/indocker/repositories/git.rb +24 -0
  70. data/lib/indocker/repositories/local.rb +20 -0
  71. data/lib/indocker/repositories/no_sync.rb +20 -0
  72. data/lib/indocker/rsync.rb +52 -0
  73. data/lib/indocker/server.rb +20 -0
  74. data/lib/indocker/server_pool.rb +30 -0
  75. data/lib/indocker/shell.rb +60 -0
  76. data/lib/indocker/ssh_result_logger.rb +18 -0
  77. data/lib/indocker/ssh_session.rb +92 -0
  78. data/lib/indocker/version.rb +1 -1
  79. data/lib/indocker/volume_helper.rb +7 -0
  80. data/lib/indocker/volumes/external.rb +8 -0
  81. data/lib/indocker/volumes/local.rb +9 -0
  82. data/lib/indocker/volumes/repository.rb +9 -0
  83. metadata +107 -222
  84. data/bin/indocker +0 -9
  85. data/lib/indocker/application_initializer.rb +0 -19
  86. data/lib/indocker/cli.rb +0 -27
  87. data/lib/indocker/configs/config.rb +0 -147
  88. data/lib/indocker/configs/config_factory.rb +0 -37
  89. data/lib/indocker/configs/config_initializer.rb +0 -9
  90. data/lib/indocker/configs/locator.rb +0 -23
  91. data/lib/indocker/container/container_builder.rb +0 -29
  92. data/lib/indocker/container/container_directives_runner.rb +0 -54
  93. data/lib/indocker/container/container_dsl.rb +0 -83
  94. data/lib/indocker/container/container_evaluator.rb +0 -13
  95. data/lib/indocker/container/container_inspector.rb +0 -26
  96. data/lib/indocker/container/container_manager.rb +0 -122
  97. data/lib/indocker/container/container_metadata.rb +0 -112
  98. data/lib/indocker/container/container_metadata_factory.rb +0 -30
  99. data/lib/indocker/container/container_metadata_repository.rb +0 -27
  100. data/lib/indocker/directives/base.rb +0 -17
  101. data/lib/indocker/directives/container_directives/base.rb +0 -23
  102. data/lib/indocker/directives/container_directives/cmd.rb +0 -7
  103. data/lib/indocker/directives/container_directives/depends_on.rb +0 -7
  104. data/lib/indocker/directives/container_directives/env.rb +0 -7
  105. data/lib/indocker/directives/container_directives/env_file.rb +0 -7
  106. data/lib/indocker/directives/container_directives/expose.rb +0 -7
  107. data/lib/indocker/directives/container_directives/from.rb +0 -14
  108. data/lib/indocker/directives/container_directives/network.rb +0 -12
  109. data/lib/indocker/directives/container_directives/ports.rb +0 -15
  110. data/lib/indocker/directives/container_directives/ready.rb +0 -16
  111. data/lib/indocker/directives/container_directives/volume.rb +0 -23
  112. data/lib/indocker/directives/image_directives/base.rb +0 -27
  113. data/lib/indocker/directives/image_directives/cmd.rb +0 -19
  114. data/lib/indocker/directives/image_directives/copy.rb +0 -32
  115. data/lib/indocker/directives/image_directives/docker_cp.rb +0 -20
  116. data/lib/indocker/directives/image_directives/entrypoint.rb +0 -19
  117. data/lib/indocker/directives/image_directives/env.rb +0 -9
  118. data/lib/indocker/directives/image_directives/env_file.rb +0 -19
  119. data/lib/indocker/directives/image_directives/expose.rb +0 -9
  120. data/lib/indocker/directives/image_directives/from.rb +0 -36
  121. data/lib/indocker/directives/image_directives/registry.rb +0 -30
  122. data/lib/indocker/directives/image_directives/run.rb +0 -17
  123. data/lib/indocker/directives/image_directives/workdir.rb +0 -9
  124. data/lib/indocker/directives/partial.rb +0 -21
  125. data/lib/indocker/docker_api/container_config.rb +0 -121
  126. data/lib/indocker/docker_api/docker_api.rb +0 -207
  127. data/lib/indocker/dsl_context.rb +0 -21
  128. data/lib/indocker/envs/env_metadata.rb +0 -39
  129. data/lib/indocker/envs/loader.rb +0 -19
  130. data/lib/indocker/errors.rb +0 -21
  131. data/lib/indocker/git/git_api.rb +0 -32
  132. data/lib/indocker/git/git_helper.rb +0 -34
  133. data/lib/indocker/git/git_service.rb +0 -21
  134. data/lib/indocker/handlers/container_run.rb +0 -20
  135. data/lib/indocker/handlers/container_stop.rb +0 -17
  136. data/lib/indocker/handlers/performable.rb +0 -22
  137. data/lib/indocker/image/image_builder.rb +0 -54
  138. data/lib/indocker/image/image_dependencies_manager.rb +0 -47
  139. data/lib/indocker/image/image_directives_runner.rb +0 -99
  140. data/lib/indocker/image/image_dockerfile_builder.rb +0 -24
  141. data/lib/indocker/image/image_dsl.rb +0 -89
  142. data/lib/indocker/image/image_evaluator.rb +0 -21
  143. data/lib/indocker/image/image_helper.rb +0 -9
  144. data/lib/indocker/image/image_metadata.rb +0 -50
  145. data/lib/indocker/image/image_metadata_factory.rb +0 -31
  146. data/lib/indocker/image/image_metadata_repository.rb +0 -29
  147. data/lib/indocker/networks/network_metadata.rb +0 -9
  148. data/lib/indocker/networks/network_metadata_factory.rb +0 -9
  149. data/lib/indocker/networks/network_metadata_repository.rb +0 -34
  150. data/lib/indocker/partial/partial_metadata.rb +0 -8
  151. data/lib/indocker/partial/partial_metadata_repository.rb +0 -26
  152. data/lib/indocker/registry/registry_api.rb +0 -46
  153. data/lib/indocker/registry/registry_helper.rb +0 -20
  154. data/lib/indocker/registry/registry_service.rb +0 -28
  155. data/lib/indocker/utils/ioc_container.rb +0 -17
  156. data/lib/indocker/utils/logger.rb +0 -62
  157. data/lib/indocker/utils/logger_factory.rb +0 -13
  158. data/lib/indocker/utils/registry_authenticator.rb +0 -19
  159. data/lib/indocker/utils/render_namespace.rb +0 -11
  160. data/lib/indocker/utils/render_util.rb +0 -15
  161. data/lib/indocker/utils/string_utils.rb +0 -11
  162. data/lib/indocker/utils/tar_helper.rb +0 -40
  163. data/lib/indocker/utils/test_logger_factory.rb +0 -9
  164. data/lib/indocker/volumes/volume_metadata.rb +0 -9
  165. data/lib/indocker/volumes/volume_metadata_factory.rb +0 -9
  166. data/lib/indocker/volumes/volume_metadata_repository.rb +0 -34
  167. data/spec/example/.indocker/config.rb +0 -30
  168. data/spec/example/.indocker/images_and_containers.rb +0 -25
  169. data/spec/example/assets/index.css +0 -1
  170. data/spec/example/assets/index.js +0 -1
  171. data/spec/fixtures/spec.env +0 -2
  172. data/spec/indocker/configs/config_factory_spec.rb +0 -18
  173. data/spec/indocker/configs/config_spec.rb +0 -88
  174. data/spec/indocker/container/container_builder_spec.rb +0 -67
  175. data/spec/indocker/container/container_manager_spec.rb +0 -278
  176. data/spec/indocker/docker_api/container_config_spec.rb +0 -64
  177. data/spec/indocker/docker_api/docker_api_spec.rb +0 -112
  178. data/spec/indocker/handlers/container_run_spec.rb +0 -60
  179. data/spec/indocker/image/image_builder_spec.rb +0 -153
  180. data/spec/indocker/image/image_directives_runner_spec.rb +0 -141
  181. data/spec/indocker/image/image_dockerfile_builder_spec.rb +0 -25
  182. data/spec/indocker/image/image_evaluator_spec.rb +0 -85
  183. data/spec/spec_helper.rb +0 -68
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3bbc0745d6bfb718696fac49f13f32af04865472
4
- data.tar.gz: 09c9a04f604edc7ac4416e4c96d1b24aff88cecb
2
+ SHA256:
3
+ metadata.gz: 1cdf31c973694a91abe68af66b52d8162884883444e4b64f1ff8d6a20e4c48a8
4
+ data.tar.gz: d9d73ae46e572e5ea2823a65b3b2bb83b94aacdafe2f5c1a22bd27b2e29d28c1
5
5
  SHA512:
6
- metadata.gz: 5063bd4bef44009433c038cc6f090aa7d89f3fc233e9f8cfee1955013aad4fa7c84c9b5110c071240b5b640ed1cb9bbaa4f6738cb5b5437dc2cf2adb9aaae661
7
- data.tar.gz: 7550ca05ad5e981a452a031de277583edef63a0456c9dca770cd6525239656ed76ced297ec5c831d85f6689c2d8800a28df62a5552d586c6ca7283ee42a63e59
6
+ metadata.gz: 74929814f68d270a04e0b3fb9d9134b594faa82f04828ff0b7785f2c654ad03c9aec99f251e4d05c5a929f30eb83b639c93acea21cca2654952615b3bafd8fe5
7
+ data.tar.gz: 7c2c091c56ecdf66071440dbd338317e95fa1e4f18e3d44d0e436bb33e14545a6afa6ef04a925f29afa9a5e5687086e38516deffadc1b9876042d5c0a8e0212f
data/.gitignore CHANGED
@@ -1,3 +1,11 @@
1
+ *.gem
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
1
10
  .DS_Store
2
- .byebug_history
3
- tmp/*
11
+ .rspec_status
data/.rspec CHANGED
@@ -1 +1,3 @@
1
+ --format documentation
2
+ --color
1
3
  --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.1
7
+ before_install: gem install bundler -v 1.17.3
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gemspec
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in indocker.gemspec
6
+ gemspec
@@ -1,67 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- indocker (0.0.5)
5
- byebug
6
- colorize
7
- docker-api
8
- docker_registry2
9
- git
10
- smart_ioc
11
- thor
4
+ indocker (0.1.4)
5
+ net-ssh
12
6
 
13
7
  GEM
14
8
  remote: https://rubygems.org/
15
9
  specs:
16
- byebug (9.1.0)
17
- colorize (0.8.1)
18
10
  diff-lcs (1.3)
19
- docker-api (1.34.0)
20
- excon (>= 0.47.0)
21
- multi_json
22
- docker_registry2 (1.3.0)
23
- rest-client (>= 1.8.0)
24
- domain_name (0.5.20170404)
25
- unf (>= 0.0.5, < 1.0.0)
26
- excon (0.59.0)
27
- git (1.3.0)
28
- http-cookie (1.0.3)
29
- domain_name (~> 0.5)
30
- mime-types (3.1)
31
- mime-types-data (~> 3.2015)
32
- mime-types-data (3.2016.0521)
33
- multi_json (1.12.2)
34
- netrc (0.11.0)
35
- rest-client (2.0.2)
36
- http-cookie (>= 1.0.2, < 2.0)
37
- mime-types (>= 1.16, < 4.0)
38
- netrc (~> 0.8)
39
- rspec (3.7.0)
40
- rspec-core (~> 3.7.0)
41
- rspec-expectations (~> 3.7.0)
42
- rspec-mocks (~> 3.7.0)
43
- rspec-core (3.7.0)
44
- rspec-support (~> 3.7.0)
45
- rspec-expectations (3.7.0)
11
+ net-ssh (6.1.0)
12
+ rake (10.5.0)
13
+ rspec (3.9.0)
14
+ rspec-core (~> 3.9.0)
15
+ rspec-expectations (~> 3.9.0)
16
+ rspec-mocks (~> 3.9.0)
17
+ rspec-core (3.9.1)
18
+ rspec-support (~> 3.9.1)
19
+ rspec-expectations (3.9.0)
46
20
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.7.0)
48
- rspec-mocks (3.7.0)
21
+ rspec-support (~> 3.9.0)
22
+ rspec-mocks (3.9.1)
49
23
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.7.0)
51
- rspec-support (3.7.0)
52
- smart_ioc (0.2.1)
53
- thor (0.20.0)
54
- unf (0.1.4)
55
- unf_ext
56
- unf_ext (0.0.7.4)
24
+ rspec-support (~> 3.9.0)
25
+ rspec-support (3.9.2)
57
26
 
58
27
  PLATFORMS
59
28
  ruby
60
29
 
61
30
  DEPENDENCIES
62
- byebug
31
+ bundler (~> 1.17)
63
32
  indocker!
64
- rspec
33
+ rake (~> 10.0)
34
+ rspec (~> 3.0)
65
35
 
66
36
  BUNDLED WITH
67
- 1.16.0.pre.3
37
+ 1.17.3
@@ -1,22 +1,21 @@
1
- Copyright (c) 2016-2017 Droidlabs
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2020 TODO: Write your name
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1 +1,20 @@
1
- DSL for build, run and deploy docker containers
1
+ # InDocker
2
+
3
+ Docker Containers Deployment
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ gem install indocker
9
+ ```
10
+
11
+ ## Development: Launch example app
12
+
13
+ ```ruby
14
+ cd example
15
+ bundle exec indocker/bin/deploy -C dev -c ruby -d
16
+ ```
17
+
18
+ ## License
19
+
20
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "indocker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative 'utils/configurations'
5
+
6
+ configurations = list_configurations(File.expand_path(File.join(__dir__, '../configurations')))
7
+
8
+ ARGV << '-h' if ARGV.empty?
9
+
10
+ options = {
11
+ skip_build: false,
12
+ force_restart: false,
13
+ skip_tags: [],
14
+ skip_force_restart: [],
15
+ }
16
+
17
+ OptionParser.new do |opts|
18
+ opts.banner = "Usage: indocker/bin/deploy [options]"
19
+
20
+ opts.on("-d", "--debug", "Debug mode") do |val|
21
+ options[:debug] = true
22
+ end
23
+
24
+ opts.on("-C", "--configuration REQUIRED", String, "Configuration name") do |val|
25
+ options[:configuration] = val
26
+ end
27
+
28
+ opts.on("-c", "--container OPTIONAL", String, "Deploy by container name") do |val|
29
+ options[:containers] ||= []
30
+ options[:containers].push(val.to_sym)
31
+ end
32
+
33
+ opts.on("-t", "--tag OPTIONAL", String, "Deploy containers by tag") do |val|
34
+ options[:tags] ||= []
35
+ options[:tags].push(val)
36
+ end
37
+
38
+ opts.on("-s", "--skip OPTIONAL", String, "Skip container during deployment") do |val|
39
+ options[:skip_containers] ||= []
40
+ options[:skip_containers] << val.to_sym
41
+ end
42
+
43
+ opts.on("-S", "--server OPTIONAL", String, "Deploy containers that include specfic server") do |val|
44
+ options[:servers] ||= []
45
+ options[:servers].push(val.to_sym)
46
+ end
47
+
48
+ opts.on("-D", "--skip-dependent", "Do not deploy dependent containers") do |val|
49
+ options[:skip_dependent] = true
50
+ end
51
+
52
+ opts.on("-f", "--force-restart", "Force to restart each container") do |val|
53
+ options[:force_restart] = true
54
+ end
55
+
56
+ opts.on("-F", "--skip-force-restart OPTIONAL", "Skip force restart of specific container for force restart mode") do |val|
57
+ options[:skip_force_restart].push(val.to_sym)
58
+ end
59
+
60
+ opts.on("-B", "--skip-build", "Skip image build") do |val|
61
+ options[:skip_build] = true
62
+ end
63
+
64
+ opts.on("-y", "--auto-confirm", "Automatically confirm deployment") do |val|
65
+ options[:auto_confirm] = true
66
+ end
67
+
68
+ opts.on("-r", "--require-confirmation", "Require deploy confirmation") do |val|
69
+ options[:require_confirmation] = true
70
+ end
71
+
72
+ opts.on("-T", "--skip-tag OPTIONAL", "Skip containers tagged by specific tags") do |val|
73
+ options[:skip_tags].push(val)
74
+ end
75
+
76
+ opts.on_tail("-h", "--help", "Show help") do
77
+ puts opts
78
+ exit
79
+ end
80
+ end.parse!
81
+
82
+ if !options.has_key?(:configuration)
83
+ puts "You should specify configuration using -C or --configuration option.\nAvailable configurations: #{configurations.sort.join(', ')}"
84
+ exit 1
85
+ end
86
+
87
+ if !configurations.include?(options[:configuration])
88
+ puts "Invalid configuration provided: #{options[:configuration]}.\nAvailable configurations: #{configurations.inspect}"
89
+ exit 1
90
+ end
91
+
92
+ begin
93
+ require 'indocker'
94
+ rescue LoadError
95
+ puts "InDocker has been moved into a separate gem. Please install using `gem install indocker`"
96
+ exit
97
+ end
98
+
99
+ if options[:debug]
100
+ Indocker.set_log_level(Logger::DEBUG)
101
+ else
102
+ Indocker.set_log_level(Logger::INFO)
103
+ end
104
+
105
+ Indocker.set_configuration_name(options[:configuration])
106
+ require_relative '../setup'
107
+
108
+ Indocker.deploy(
109
+ containers: options[:containers] || [],
110
+ tags: options[:tags] || [],
111
+ skip_containers: options[:skip_containers] || [],
112
+ skip_dependent: !!options[:skip_dependent],
113
+ servers: options[:servers] || [],
114
+ skip_build: options[:skip_build],
115
+ force_restart: options[:force_restart],
116
+ skip_tags: options[:skip_tags] || [],
117
+ skip_force_restart: options[:skip_force_restart] || [],
118
+ auto_confirm: !!options[:auto_confirm],
119
+ require_confirmation: !!options[:require_confirmation],
120
+ )
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../utils/configurations'
5
+
6
+ configurations = list_configurations(File.expand_path(File.join(__dir__, '../../configurations')))
7
+
8
+ ARGV << '-h' if ARGV.empty?
9
+
10
+ options = {}
11
+
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: indocker/bin/remote/compile [options] (only on remote server)"
14
+
15
+ opts.on("-C", "--configuration REQUIRED", String, "Configuration name") do |val|
16
+ options[:configuration] = val
17
+ end
18
+
19
+ opts.on("-d", "--debug", "Debug mode") do |val|
20
+ options[:debug] = true
21
+ end
22
+
23
+ opts.on("-i", "--image REQUIRED", String, "Image to be compiled") do |val|
24
+ options[:images] ||= []
25
+ options[:images].push(val.to_sym)
26
+ end
27
+
28
+ opts.on("-s", "--skip-dependent", String, "Do not compile dependent images") do |val|
29
+ options[:skip_dependent] = true
30
+ end
31
+
32
+ opts.on_tail("-h", "--help", "Show help") do
33
+ puts opts
34
+ exit
35
+ end
36
+ end.parse!
37
+
38
+ if !options.has_key?(:configuration)
39
+ puts "You should specify configuration using -C or --configuration option.\nAvailable configurations: #{configurations.sort.join(', ')}"
40
+ exit 1
41
+ end
42
+
43
+ if !configurations.include?(options[:configuration])
44
+ puts "Invalid configuration provided: #{options[:configuration]}.\nAvailable configurations: #{configurations.inspect}"
45
+ exit 1
46
+ end
47
+
48
+ if !options.has_key?(:images)
49
+ puts "At least one image should be provided"
50
+ end
51
+
52
+ begin
53
+ require 'indocker'
54
+ rescue LoadError
55
+ puts "InDocker has been moved into a separate gem. Please install using `gem install indocker`"
56
+ exit 1
57
+ end
58
+
59
+ if options[:debug]
60
+ Indocker.set_log_level(Logger::DEBUG)
61
+ else
62
+ Indocker.set_log_level(Logger::INFO)
63
+ end
64
+
65
+ Indocker.set_configuration_name(options[:configuration])
66
+ require_relative '../../setup'
67
+
68
+
69
+ Indocker.compile(
70
+ images: options[:images] || [],
71
+ skip_dependent: !!options[:skip_dependent]
72
+ )
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../utils/configurations'
5
+
6
+ configurations = list_configurations(File.expand_path(File.join(__dir__, '../../configurations')))
7
+
8
+ ARGV << '-h' if ARGV.empty?
9
+
10
+ options = {
11
+ force_restart: false,
12
+ }
13
+
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: indocker/bin/remote/run [options] (only on remove server)"
16
+
17
+ opts.on("-C", "--configuration REQUIRED", String, "Configuration name") do |val|
18
+ options[:configuration] = val
19
+ end
20
+
21
+ opts.on("-d", "--debug", "Debug mode") do |val|
22
+ options[:debug] = true
23
+ end
24
+
25
+ opts.on("-c", "--container REQUIRED", String, "Container name") do |val|
26
+ options[:container] = val.to_sym
27
+ end
28
+
29
+ opts.on("-f", "--force-restart", "Force to restart each container") do |val|
30
+ options[:force_restart] = true
31
+ end
32
+
33
+ opts.on_tail("-h", "--help", "Show help") do
34
+ puts opts
35
+ exit
36
+ end
37
+ end.parse!
38
+
39
+ if !options.has_key?(:configuration)
40
+ puts "You should specify configuration using -C or --configuration option.\nAvailable configurations: #{configurations.sort.join(', ')}"
41
+ exit 1
42
+ end
43
+
44
+ if !configurations.include?(options[:configuration])
45
+ puts "Invalid configuration provided: #{options[:configuration]}.\nAvailable configurations: #{configurations.inspect}"
46
+ exit 1
47
+ end
48
+
49
+ begin
50
+ require 'indocker'
51
+ rescue LoadError
52
+ puts "InDocker has been moved into a separate gem. Please install using `gem install indocker`"
53
+ exit 1
54
+ end
55
+
56
+ if options[:debug]
57
+ Indocker.set_log_level(Logger::DEBUG)
58
+ else
59
+ Indocker.set_log_level(Logger::INFO)
60
+ end
61
+
62
+ Indocker.set_configuration_name(options[:configuration])
63
+ require_relative '../../setup'
64
+
65
+
66
+ Indocker.run(options[:container], options[:force_restart])