indocker 0.0.6 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,15 +0,0 @@
1
- class Indocker::ContainerDirectives::Ports < Indocker::ContainerDirectives::Base
2
- attr_accessor :container_port, :host_port
3
-
4
- def initialize(container_port:, host_port:)
5
- @container_port = container_port
6
- @host_port = host_port
7
- end
8
-
9
- def to_hash
10
- {
11
- container_port: @container_port,
12
- host_port: @host_port
13
- }
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- class Indocker::ContainerDirectives::Ready < Indocker::ContainerDirectives::Base
2
- attr_accessor :ready_block, :sleep, :timeout
3
-
4
- DEFAULT_SLEEP = 0.1
5
- DEFAULT_TIMEPUT = 10
6
-
7
- def initialize(sleep: DEFAULT_SLEEP, timeout: DEFAULT_TIMEPUT, ready_block:)
8
- @sleep = sleep
9
- @timeout = timeout
10
- @ready_block = ready_block
11
- end
12
-
13
- def after_start?
14
- true
15
- end
16
- end
@@ -1,23 +0,0 @@
1
- class Indocker::ContainerDirectives::Volume < Indocker::ContainerDirectives::Base
2
- attr_accessor :name, :to
3
-
4
- def initialize(name:, to:)
5
- @name = name
6
- @to = to
7
- end
8
-
9
- def before_start?
10
- true
11
- end
12
-
13
- def to_hash
14
- {
15
- name: @name,
16
- to: @to
17
- }
18
- end
19
-
20
- def docker_name
21
- '/' + @name.to_s.gsub(/(\A\/)/, '')
22
- end
23
- end
@@ -1,27 +0,0 @@
1
- module Indocker
2
- module ImageDirectives
3
- class Base < Indocker::Directives::Base
4
- attr_reader :args
5
-
6
- def initialize(*args)
7
- @args = args
8
- end
9
-
10
- def to_s
11
- "#{type} #{@args.join(' ')}"
12
- end
13
-
14
- def prepare_directive?
15
- false
16
- end
17
-
18
- def build_directive?
19
- false
20
- end
21
-
22
- def after_build_directive?
23
- false
24
- end
25
- end
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- class Indocker::ImageDirectives::Cmd < Indocker::ImageDirectives::Base
2
- attr_reader :command
3
-
4
- def initialize(command)
5
- @command = command
6
- end
7
-
8
- def to_s
9
- "#{type} #{command.inspect}"
10
- end
11
-
12
- def type
13
- 'CMD'
14
- end
15
-
16
- def build_directive?
17
- true
18
- end
19
- end
@@ -1,32 +0,0 @@
1
- class Indocker::ImageDirectives::Copy < Indocker::ImageDirectives::Base
2
- attr_reader :copy_actions, :compile, :locals, :build_dir
3
-
4
- def initialize(copy_actions:, compile:, locals:, build_dir:)
5
- @copy_actions = copy_actions
6
- @compile = compile
7
- @locals = locals
8
- @build_dir = build_dir
9
- end
10
-
11
- def type
12
- 'COPY'
13
- end
14
-
15
- def to_s
16
- result = []
17
-
18
- copy_actions.each do |from, to|
19
- result.push "#{type} #{from} #{to}"
20
- end
21
-
22
- result.join("\n")
23
- end
24
-
25
- def prepare_directive?
26
- true
27
- end
28
-
29
- def build_directive?
30
- true
31
- end
32
- end
@@ -1,20 +0,0 @@
1
- class Indocker::ImageDirectives::DockerCp < Indocker::ImageDirectives::Base
2
- attr_reader :container_name, :copy_actions, :build_dir
3
-
4
- def initialize(container_name, build_dir, &block)
5
- @container_name = container_name
6
- @build_dir = build_dir
7
-
8
- instance_exec &block if block_given?
9
- end
10
-
11
- def prepare_directive?
12
- true
13
- end
14
-
15
- private
16
-
17
- def copy(copy_actions)
18
- @copy_actions = copy_actions
19
- end
20
- end
@@ -1,19 +0,0 @@
1
- class Indocker::ImageDirectives::Entrypoint < Indocker::ImageDirectives::Base
2
- attr_reader :command
3
-
4
- def initialize(command)
5
- @command = command
6
- end
7
-
8
- def to_s
9
- "#{type} #{command.inspect}"
10
- end
11
-
12
- def type
13
- 'ENTRYPOINT'
14
- end
15
-
16
- def build_directive?
17
- true
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- class Indocker::ImageDirectives::Env < Indocker::ImageDirectives::Base
2
- def type
3
- 'ENV'
4
- end
5
-
6
- def build_directive?
7
- true
8
- end
9
- end
@@ -1,19 +0,0 @@
1
- class Indocker::ImageDirectives::EnvFile < Indocker::ImageDirectives::Base
2
- attr_reader :path
3
-
4
- def initialize(path)
5
- @path = path
6
- end
7
-
8
- def type
9
- 'ENV'
10
- end
11
-
12
- def to_s(env_string)
13
- "#{type} #{env_string}"
14
- end
15
-
16
- def build_directive?
17
- true
18
- end
19
- end
@@ -1,9 +0,0 @@
1
- class Indocker::ImageDirectives::Expose < Indocker::ImageDirectives::Base
2
- def type
3
- 'EXPOSE'
4
- end
5
-
6
- def build_directive?
7
- true
8
- end
9
- end
@@ -1,36 +0,0 @@
1
- class Indocker::ImageDirectives::From < Indocker::ImageDirectives::Base
2
- include Indocker::ImageHelper
3
-
4
- attr_reader :repo, :tag
5
-
6
- def initialize(repo_tag, tag: nil)
7
- case repo_tag
8
- when String
9
- @repo = repo_tag.split(':')[0]
10
- @tag = tag || repo_tag.split(':')[1] || Indocker::ImageHelper::DEFAULT_TAG
11
- else
12
- @repo = repo_tag
13
- @tag = tag || Indocker::ImageHelper::DEFAULT_TAG
14
- end
15
- end
16
-
17
- def full_name
18
- super(@repo, @tag)
19
- end
20
-
21
- def dockerhub_image?
22
- repo.is_a?(String)
23
- end
24
-
25
- def to_s
26
- "#{type} #{full_name}"
27
- end
28
-
29
- def type
30
- 'FROM'
31
- end
32
-
33
- def build_directive?
34
- true
35
- end
36
- end
@@ -1,30 +0,0 @@
1
- class Indocker::ImageDirectives::Registry < Indocker::ImageDirectives::Base
2
- attr_reader :registry, :push, :repo, :tag
3
-
4
- def initialize(repo:, tag:, registry:, push:)
5
- @repo = repo.to_s
6
- @tag = tag.to_s
7
- @registry = format_registry(registry)
8
- @push = push
9
- end
10
-
11
- def new_repo
12
- "#{@registry}/#{@repo}"
13
- end
14
-
15
- def new_tag
16
- @tag
17
- end
18
-
19
- def after_build_directive?
20
- true
21
- end
22
-
23
- private
24
-
25
- def format_registry(serveraddress)
26
- serveraddress
27
- .gsub('http://', '')
28
- .gsub(/\/\Z/, '')
29
- end
30
- end
@@ -1,17 +0,0 @@
1
- class Indocker::ImageDirectives::Run < Indocker::ImageDirectives::Base
2
- def type
3
- 'RUN'
4
- end
5
-
6
- def initialize(command)
7
- @command = command.split("\n").map(&:strip).join(' ')
8
- end
9
-
10
- def to_s
11
- "#{type} #{@command}"
12
- end
13
-
14
- def build_directive?
15
- true
16
- end
17
- end
@@ -1,9 +0,0 @@
1
- class Indocker::ImageDirectives::Workdir < Indocker::ImageDirectives::Base
2
- def type
3
- 'WORKDIR'
4
- end
5
-
6
- def build_directive?
7
- true
8
- end
9
- end
@@ -1,21 +0,0 @@
1
- class Indocker::Directives::Partial < Indocker::Directives::Base
2
- attr_reader :name
3
-
4
- def initialize(name, context, opts = {})
5
- @name = name
6
- @context = context
7
- @opts = opts
8
- end
9
-
10
- def to_s
11
- inspect
12
- end
13
-
14
- def context
15
- @context + Indocker::DSLContext.new(@opts)
16
- end
17
-
18
- def partial_directive?
19
- true
20
- end
21
- end
@@ -1,121 +0,0 @@
1
- class Indocker::DockerAPI::ContainerConfig
2
- include Indocker::ImageHelper
3
-
4
- attr_reader :image, :name, :cmd, :env, :exposed_ports, :host_config, :volumes_config
5
-
6
- CONTAINER_DEFAULT_OPTIONS = {
7
- 'Tty' => true,
8
- 'OpenStdin' => true,
9
- 'StdinOnce' => true,
10
- 'AttachStdin' => true,
11
- 'AttachStdout' => true
12
- }
13
-
14
- def initialize(
15
- name:,
16
- repo: nil,
17
- tag: nil,
18
- image: nil,
19
- cmd: nil,
20
- env: '',
21
- volumes: [],
22
- binds: [],
23
- exposed_ports: nil,
24
- port_bindings: nil
25
- )
26
-
27
- @image = image_full_name(image, repo, tag)
28
- @name = name
29
- @cmd = cmd
30
- @env = env
31
- @exposed_ports = ExposedPortsConfig.new(exposed_ports)
32
- @host_config = HostConfig.new(port_bindings, binds)
33
- @volumes_config = VolumesConfig.new(volumes)
34
- end
35
-
36
- def ==(other)
37
- self.to_hash == other.to_hash
38
- end
39
-
40
- def image_full_name(image = nil, repo = nil, tag = nil)
41
- result = image || full_name(repo, tag)
42
- raise ArgumentError if result.to_s.empty?
43
-
44
- result
45
- end
46
-
47
- def to_hash
48
- state_config = {
49
- 'Image' => @image,
50
- 'name' => @name,
51
- 'Cmd' => @cmd,
52
- 'Env' => @env,
53
- 'ExposedPorts' => @exposed_ports.to_hash,
54
- 'Volumes' => @volumes_config.to_hash,
55
- 'HostConfig' => @host_config.to_hash
56
- }
57
-
58
- CONTAINER_DEFAULT_OPTIONS
59
- .merge(state_config)
60
- .delete_if {|_, value| value.to_s.empty?}
61
- end
62
-
63
- class ExposedPortsConfig
64
- attr_reader :ports
65
-
66
- def initialize(ports)
67
- @ports = ports || []
68
- end
69
-
70
- def to_hash
71
- @ports.inject({}) do |result, value|
72
- result[value] = {}
73
- result
74
- end
75
- end
76
- end
77
-
78
- class VolumesConfig
79
- attr_reader :volumes
80
-
81
- VOLUME_VALUE = {}
82
-
83
- def initialize(volumes)
84
- @volumes = volumes || []
85
- end
86
-
87
- def to_hash
88
- volumes.inject({}) do |config, volume|
89
- config[volume] = {}
90
- config
91
- end
92
- end
93
- end
94
-
95
- class HostConfig
96
- attr_reader :port_bindings, :binds
97
-
98
- def initialize(port_bindings, binds)
99
- @port_bindings = port_bindings || {}
100
- @binds = binds || {}
101
- end
102
-
103
- def to_hash
104
- format_port_bindings = port_bindings.inject({}) do |result, value|
105
- result[value[:container_port]] = [{ "HostPort" => value[:host_port] }]
106
- result
107
- end
108
-
109
- format_binds = binds.inject([]) do |result, value|
110
- result.push("#{value[:name]}:#{value[:to]}")
111
- result
112
- end
113
-
114
- {
115
- 'Binds' => format_binds,
116
- 'PortBindings' => format_port_bindings
117
- }
118
- end
119
- end
120
- end
121
-