indocker 0.0.6 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +10 -2
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Gemfile +5 -2
- data/Gemfile.lock +19 -49
- data/LICENSE.txt +17 -18
- data/README.md +20 -1
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/indocker/bin/deploy +120 -0
- data/example/indocker/bin/remote/compile +72 -0
- data/example/indocker/bin/remote/run +66 -0
- data/example/indocker/bin/utils/configurations.rb +3 -0
- data/example/indocker/bounded_contexts/shared/ruby/Dockerfile +10 -0
- data/example/indocker/bounded_contexts/shared/ruby/container.rb +5 -0
- data/example/indocker/bounded_contexts/shared/ruby/image.rb +3 -0
- data/example/indocker/configurations/dev.rb +9 -0
- data/example/indocker/infrastructure/build_servers.rb +8 -0
- data/example/indocker/infrastructure/networks.rb +1 -0
- data/example/indocker/infrastructure/registries.rb +3 -0
- data/example/indocker/infrastructure/servers.rb +8 -0
- data/example/indocker/setup.rb +24 -0
- data/indocker.gemspec +27 -25
- data/lib/indocker.rb +437 -130
- data/lib/indocker/artifacts/git.rb +25 -0
- data/lib/indocker/build_context.rb +87 -0
- data/lib/indocker/build_context_helper.rb +109 -0
- data/lib/indocker/build_context_pool.rb +36 -0
- data/lib/indocker/build_server.rb +2 -0
- data/lib/indocker/colored_string.rb +33 -0
- data/lib/indocker/concerns/inspectable.rb +12 -0
- data/lib/indocker/configuration_deployer.rb +525 -0
- data/lib/indocker/configurations/configuration.rb +122 -0
- data/lib/indocker/configurations/configuration_builder.rb +250 -0
- data/lib/indocker/configurations/formatters/stdout.rb +36 -0
- data/lib/indocker/container_deployer.rb +73 -0
- data/lib/indocker/container_helper.rb +13 -0
- data/lib/indocker/container_runner.rb +23 -0
- data/lib/indocker/containers/container.rb +118 -0
- data/lib/indocker/containers/container_builder.rb +186 -0
- data/lib/indocker/containers/restart_policy.rb +36 -0
- data/lib/indocker/context_args.rb +43 -0
- data/lib/indocker/crontab_redeploy_rules_builder.rb +54 -0
- data/lib/indocker/deploy_context.rb +126 -0
- data/lib/indocker/deployment_checker.rb +121 -0
- data/lib/indocker/deployment_progress.rb +495 -0
- data/lib/indocker/docker.rb +87 -0
- data/lib/indocker/docker_run_args.rb +183 -0
- data/lib/indocker/env_file_helper.rb +13 -0
- data/lib/indocker/env_files/local.rb +8 -0
- data/lib/indocker/env_files/remote.rb +8 -0
- data/lib/indocker/hash_merger.rb +9 -0
- data/lib/indocker/images/image.rb +86 -0
- data/lib/indocker/images/image_builder.rb +98 -0
- data/lib/indocker/images/image_compiler.rb +68 -0
- data/lib/indocker/images/template_compiler.rb +15 -0
- data/lib/indocker/images/templates_compiler.rb +28 -0
- data/lib/indocker/images_compiler.rb +38 -0
- data/lib/indocker/indocker_helper.rb +9 -0
- data/lib/indocker/network.rb +12 -0
- data/lib/indocker/network_helper.rb +7 -0
- data/lib/indocker/registries/abstract.rb +17 -0
- data/lib/indocker/registries/local.rb +5 -0
- data/lib/indocker/registries/remote.rb +12 -0
- data/lib/indocker/repositories/abstract.rb +25 -0
- data/lib/indocker/repositories/clonner.rb +17 -0
- data/lib/indocker/repositories/git.rb +24 -0
- data/lib/indocker/repositories/local.rb +20 -0
- data/lib/indocker/repositories/no_sync.rb +20 -0
- data/lib/indocker/rsync.rb +52 -0
- data/lib/indocker/server.rb +20 -0
- data/lib/indocker/server_pool.rb +30 -0
- data/lib/indocker/shell.rb +60 -0
- data/lib/indocker/ssh_result_logger.rb +18 -0
- data/lib/indocker/ssh_session.rb +92 -0
- data/lib/indocker/version.rb +1 -1
- data/lib/indocker/volume_helper.rb +7 -0
- data/lib/indocker/volumes/external.rb +8 -0
- data/lib/indocker/volumes/local.rb +9 -0
- data/lib/indocker/volumes/repository.rb +9 -0
- metadata +107 -222
- data/bin/indocker +0 -9
- data/lib/indocker/application_initializer.rb +0 -19
- data/lib/indocker/cli.rb +0 -27
- data/lib/indocker/configs/config.rb +0 -147
- data/lib/indocker/configs/config_factory.rb +0 -37
- data/lib/indocker/configs/config_initializer.rb +0 -9
- data/lib/indocker/configs/locator.rb +0 -23
- data/lib/indocker/container/container_builder.rb +0 -29
- data/lib/indocker/container/container_directives_runner.rb +0 -54
- data/lib/indocker/container/container_dsl.rb +0 -83
- data/lib/indocker/container/container_evaluator.rb +0 -13
- data/lib/indocker/container/container_inspector.rb +0 -26
- data/lib/indocker/container/container_manager.rb +0 -122
- data/lib/indocker/container/container_metadata.rb +0 -112
- data/lib/indocker/container/container_metadata_factory.rb +0 -30
- data/lib/indocker/container/container_metadata_repository.rb +0 -27
- data/lib/indocker/directives/base.rb +0 -17
- data/lib/indocker/directives/container_directives/base.rb +0 -23
- data/lib/indocker/directives/container_directives/cmd.rb +0 -7
- data/lib/indocker/directives/container_directives/depends_on.rb +0 -7
- data/lib/indocker/directives/container_directives/env.rb +0 -7
- data/lib/indocker/directives/container_directives/env_file.rb +0 -7
- data/lib/indocker/directives/container_directives/expose.rb +0 -7
- data/lib/indocker/directives/container_directives/from.rb +0 -14
- data/lib/indocker/directives/container_directives/network.rb +0 -12
- data/lib/indocker/directives/container_directives/ports.rb +0 -15
- data/lib/indocker/directives/container_directives/ready.rb +0 -16
- data/lib/indocker/directives/container_directives/volume.rb +0 -23
- data/lib/indocker/directives/image_directives/base.rb +0 -27
- data/lib/indocker/directives/image_directives/cmd.rb +0 -19
- data/lib/indocker/directives/image_directives/copy.rb +0 -32
- data/lib/indocker/directives/image_directives/docker_cp.rb +0 -20
- data/lib/indocker/directives/image_directives/entrypoint.rb +0 -19
- data/lib/indocker/directives/image_directives/env.rb +0 -9
- data/lib/indocker/directives/image_directives/env_file.rb +0 -19
- data/lib/indocker/directives/image_directives/expose.rb +0 -9
- data/lib/indocker/directives/image_directives/from.rb +0 -36
- data/lib/indocker/directives/image_directives/registry.rb +0 -30
- data/lib/indocker/directives/image_directives/run.rb +0 -17
- data/lib/indocker/directives/image_directives/workdir.rb +0 -9
- data/lib/indocker/directives/partial.rb +0 -21
- data/lib/indocker/docker_api/container_config.rb +0 -121
- data/lib/indocker/docker_api/docker_api.rb +0 -207
- data/lib/indocker/dsl_context.rb +0 -21
- data/lib/indocker/envs/env_metadata.rb +0 -39
- data/lib/indocker/envs/loader.rb +0 -19
- data/lib/indocker/errors.rb +0 -21
- data/lib/indocker/git/git_api.rb +0 -32
- data/lib/indocker/git/git_helper.rb +0 -34
- data/lib/indocker/git/git_service.rb +0 -21
- data/lib/indocker/handlers/container_run.rb +0 -20
- data/lib/indocker/handlers/container_stop.rb +0 -17
- data/lib/indocker/handlers/performable.rb +0 -22
- data/lib/indocker/image/image_builder.rb +0 -54
- data/lib/indocker/image/image_dependencies_manager.rb +0 -47
- data/lib/indocker/image/image_directives_runner.rb +0 -99
- data/lib/indocker/image/image_dockerfile_builder.rb +0 -24
- data/lib/indocker/image/image_dsl.rb +0 -89
- data/lib/indocker/image/image_evaluator.rb +0 -21
- data/lib/indocker/image/image_helper.rb +0 -9
- data/lib/indocker/image/image_metadata.rb +0 -50
- data/lib/indocker/image/image_metadata_factory.rb +0 -31
- data/lib/indocker/image/image_metadata_repository.rb +0 -29
- data/lib/indocker/networks/network_metadata.rb +0 -9
- data/lib/indocker/networks/network_metadata_factory.rb +0 -9
- data/lib/indocker/networks/network_metadata_repository.rb +0 -34
- data/lib/indocker/partial/partial_metadata.rb +0 -8
- data/lib/indocker/partial/partial_metadata_repository.rb +0 -26
- data/lib/indocker/registry/registry_api.rb +0 -46
- data/lib/indocker/registry/registry_helper.rb +0 -20
- data/lib/indocker/registry/registry_service.rb +0 -28
- data/lib/indocker/utils/ioc_container.rb +0 -17
- data/lib/indocker/utils/logger.rb +0 -62
- data/lib/indocker/utils/logger_factory.rb +0 -13
- data/lib/indocker/utils/registry_authenticator.rb +0 -19
- data/lib/indocker/utils/render_namespace.rb +0 -11
- data/lib/indocker/utils/render_util.rb +0 -15
- data/lib/indocker/utils/string_utils.rb +0 -11
- data/lib/indocker/utils/tar_helper.rb +0 -40
- data/lib/indocker/utils/test_logger_factory.rb +0 -9
- data/lib/indocker/volumes/volume_metadata.rb +0 -9
- data/lib/indocker/volumes/volume_metadata_factory.rb +0 -9
- data/lib/indocker/volumes/volume_metadata_repository.rb +0 -34
- data/spec/example/.indocker/config.rb +0 -30
- data/spec/example/.indocker/images_and_containers.rb +0 -25
- data/spec/example/assets/index.css +0 -1
- data/spec/example/assets/index.js +0 -1
- data/spec/fixtures/spec.env +0 -2
- data/spec/indocker/configs/config_factory_spec.rb +0 -18
- data/spec/indocker/configs/config_spec.rb +0 -88
- data/spec/indocker/container/container_builder_spec.rb +0 -67
- data/spec/indocker/container/container_manager_spec.rb +0 -278
- data/spec/indocker/docker_api/container_config_spec.rb +0 -64
- data/spec/indocker/docker_api/docker_api_spec.rb +0 -112
- data/spec/indocker/handlers/container_run_spec.rb +0 -60
- data/spec/indocker/image/image_builder_spec.rb +0 -153
- data/spec/indocker/image/image_directives_runner_spec.rb +0 -141
- data/spec/indocker/image/image_dockerfile_builder_spec.rb +0 -25
- data/spec/indocker/image/image_evaluator_spec.rb +0 -85
- 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,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,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,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
|
-
|