indocker 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/example/indocker/bounded_contexts/shared/{container_failing_build → bad_container_build}/Dockerfile +0 -1
- data/example/indocker/bounded_contexts/shared/bad_container_build/container.rb +5 -0
- data/example/indocker/bounded_contexts/shared/bad_container_build/image.rb +3 -0
- data/example/indocker/bounded_contexts/shared/bad_container_start/Dockerfile +8 -0
- data/example/indocker/bounded_contexts/shared/bad_container_start/build_context/bin/run +3 -0
- data/example/indocker/bounded_contexts/shared/bad_container_start/container.rb +5 -0
- data/example/indocker/bounded_contexts/shared/bad_container_start/image.rb +3 -0
- data/example/indocker/bounded_contexts/shared/good_container/Dockerfile +4 -0
- data/example/indocker/bounded_contexts/shared/good_container/container.rb +5 -0
- data/example/indocker/bounded_contexts/shared/good_container/image.rb +3 -0
- data/example/indocker/configurations/external.rb +7 -1
- data/example/spec/indocker_spec.rb +11 -3
- data/lib/indocker.rb +0 -1
- data/lib/indocker/build_context.rb +3 -4
- data/lib/indocker/build_context_pool.rb +2 -4
- data/lib/indocker/configuration_deployer.rb +13 -7
- data/lib/indocker/container_deployer.rb +13 -6
- data/lib/indocker/images_compiler.rb +1 -2
- data/lib/indocker/ssh_session.rb +21 -10
- data/lib/indocker/version.rb +1 -1
- metadata +12 -6
- data/example/indocker/bounded_contexts/shared/container_failing_build/container.rb +0 -5
- data/example/indocker/bounded_contexts/shared/container_failing_build/image.rb +0 -3
- data/lib/indocker/ssh_result_logger.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8625d37ada817f2f83c30f154bd2ed9a104a023e5b554f4c91f3708ed4aa2770
|
4
|
+
data.tar.gz: 24950eb94bd956f7f10ad81da4330bffa78495a4852733a1bec5d0713cce4896
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e50ef7ed88a688bb1119e55b1d1662d6827e5667cc66c61dc85933687e9d4834c785c03c7fb917a2709adf04d909f7e611f8c844741b1532211dddad340dc149
|
7
|
+
data.tar.gz: 1e52f25fff3bf09ddb7f1d097b46ad0e858555892d3b4721a628c8817a16e165694dbf3650e940eb83cb6ac05d8ded47c6359ada9d3cba39d3885ff95e9e88d0
|
data/Gemfile.lock
CHANGED
@@ -8,14 +8,14 @@ RSpec.describe Indocker do
|
|
8
8
|
describe "successful deployment" do
|
9
9
|
it "doesn't raise any error" do
|
10
10
|
expect{
|
11
|
-
launch_deployment(containers: [:
|
11
|
+
launch_deployment(containers: [:good_container])
|
12
12
|
}.to_not raise_error
|
13
13
|
end
|
14
14
|
|
15
15
|
it "shows a message about successful deploy" do
|
16
16
|
allow(Indocker.global_logger).to receive(:info).at_least(:once)
|
17
17
|
|
18
|
-
launch_deployment(containers: [:
|
18
|
+
launch_deployment(containers: [:good_container])
|
19
19
|
|
20
20
|
expect(Indocker.global_logger).to have_received(:info).at_least(:once).with(/Deployment finished/)
|
21
21
|
end
|
@@ -24,8 +24,16 @@ RSpec.describe Indocker do
|
|
24
24
|
describe "failed build" do
|
25
25
|
it "exits with an error" do
|
26
26
|
expect{
|
27
|
-
launch_deployment(containers: [:
|
27
|
+
launch_deployment(containers: [:bad_container_build])
|
28
28
|
}.to raise_error(SystemExit)
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
describe "failed start" do
|
33
|
+
it "exits without error" do
|
34
|
+
expect{
|
35
|
+
launch_deployment(containers: [:bad_container_start])
|
36
|
+
}.to_not raise_error(SystemExit)
|
37
|
+
end
|
38
|
+
end
|
31
39
|
end
|
data/lib/indocker.rb
CHANGED
@@ -85,7 +85,6 @@ module Indocker
|
|
85
85
|
autoload :IndockerHelper, 'indocker_helper'
|
86
86
|
autoload :ImagesCompiler, 'images_compiler'
|
87
87
|
autoload :ContainerRunner, 'container_runner'
|
88
|
-
autoload :SshResultLogger, 'ssh_result_logger'
|
89
88
|
autoload :DeploymentProgress, 'deployment_progress'
|
90
89
|
autoload :DeploymentChecker, 'deployment_checker'
|
91
90
|
autoload :DeploymentPolicy, 'deployment_policy'
|
@@ -3,12 +3,11 @@ require 'fileutils'
|
|
3
3
|
class Indocker::BuildContext
|
4
4
|
attr_reader :session, :server, :configuration, :helper, :logger
|
5
5
|
|
6
|
-
def initialize(configuration:, build_server:, logger
|
6
|
+
def initialize(configuration:, build_server:, logger:)
|
7
7
|
@configuration = configuration
|
8
8
|
@logger = logger
|
9
9
|
@helper = Indocker::BuildContextHelper.new(@configuration, @build_server)
|
10
10
|
@server = build_server
|
11
|
-
@global_logger = global_logger
|
12
11
|
@compiled_images = Hash.new(false)
|
13
12
|
end
|
14
13
|
|
@@ -73,8 +72,8 @@ class Indocker::BuildContext
|
|
73
72
|
res = Indocker::Docker.build(image.local_registry_url, build_args)
|
74
73
|
|
75
74
|
if res.exit_status != 0
|
76
|
-
|
77
|
-
|
75
|
+
puts "image compilation :#{image.name} failed"
|
76
|
+
puts res.stdout
|
78
77
|
exit 1
|
79
78
|
end
|
80
79
|
|
@@ -1,15 +1,13 @@
|
|
1
1
|
class Indocker::BuildContextPool
|
2
|
-
def initialize(configuration:, logger
|
2
|
+
def initialize(configuration:, logger:)
|
3
3
|
@logger = logger
|
4
4
|
@configuration = configuration
|
5
|
-
@global_logger = global_logger
|
6
5
|
|
7
6
|
@contexts = configuration.build_servers.map do |build_server|
|
8
7
|
Indocker::BuildContext.new(
|
9
8
|
logger: @logger,
|
10
9
|
configuration: configuration,
|
11
|
-
build_server: build_server
|
12
|
-
global_logger: @global_logger,
|
10
|
+
build_server: build_server
|
13
11
|
)
|
14
12
|
end
|
15
13
|
end
|
@@ -46,7 +46,7 @@ class Indocker::ConfigurationDeployer
|
|
46
46
|
containers = find_containers_to_deploy(configuration, deployment_policy)
|
47
47
|
|
48
48
|
clonner = Indocker::Repositories::Clonner.new(configuration, @logger)
|
49
|
-
build_context_pool = Indocker::BuildContextPool.new(configuration: configuration, logger: @logger
|
49
|
+
build_context_pool = Indocker::BuildContextPool.new(configuration: configuration, logger: @logger)
|
50
50
|
deployer = Indocker::ContainerDeployer.new(configuration: configuration, logger: @logger)
|
51
51
|
|
52
52
|
@global_logger.info("Establishing ssh sessions to all servers...")
|
@@ -290,15 +290,21 @@ class Indocker::ConfigurationDeployer
|
|
290
290
|
result = build_context
|
291
291
|
.session
|
292
292
|
.exec!(
|
293
|
-
"cd #{Indocker::IndockerHelper.indocker_dir} && ./bin/remote/compile -C #{Indocker.configuration_name} -i #{image.name} -s #{@logger.debug? ? '-d' : ''}"
|
293
|
+
"cd #{Indocker::IndockerHelper.indocker_dir} && ./bin/remote/compile -C #{Indocker.configuration_name} -i #{image.name} -s #{@logger.debug? ? '-d' : ''}",
|
294
|
+
on_stdout: proc { |data|
|
295
|
+
@logger.info("[compile] #{data}")
|
296
|
+
},
|
297
|
+
on_stderr: proc { |data|
|
298
|
+
@logger.error("[compile] #{data}")
|
299
|
+
}
|
294
300
|
)
|
295
301
|
end
|
296
302
|
|
297
|
-
|
298
|
-
.
|
299
|
-
|
300
|
-
|
301
|
-
|
303
|
+
if result.exit_code != 0
|
304
|
+
@global_logger.error("[compile] #{image.name.to_s.green} image compilation failed")
|
305
|
+
puts result.stdout_data
|
306
|
+
exit 1
|
307
|
+
end
|
302
308
|
|
303
309
|
@logger.info("Image compilation completed #{image.name.to_s.green}. Time taken: #{time}")
|
304
310
|
|
@@ -50,14 +50,21 @@ class Indocker::ContainerDeployer
|
|
50
50
|
result = deploy_context
|
51
51
|
.session
|
52
52
|
.exec!(
|
53
|
-
"cd #{Indocker::IndockerHelper.indocker_dir} && ./bin/remote/run -C #{Indocker.configuration_name} -c #{container.name} #{debug_options} #{command_output} #{force_restart_options}"
|
53
|
+
"cd #{Indocker::IndockerHelper.indocker_dir} && ./bin/remote/run -C #{Indocker.configuration_name} -c #{container.name} #{debug_options} #{command_output} #{force_restart_options}",
|
54
|
+
on_stdout: proc { |data|
|
55
|
+
@logger.info("[deploy] #{data}")
|
56
|
+
},
|
57
|
+
on_stderr: proc { |data|
|
58
|
+
@logger.error("[deploy] #{data}")
|
59
|
+
}
|
54
60
|
)
|
61
|
+
|
62
|
+
if result.exit_code != 0
|
63
|
+
@global_logger.error("[deploy] #{container.name.to_s.green} deployment for server #{server.name} failed")
|
64
|
+
puts result.stdout_data
|
65
|
+
exit 1
|
66
|
+
end
|
55
67
|
|
56
|
-
Indocker::SshResultLogger
|
57
|
-
.new(@logger)
|
58
|
-
.log(result, "#{container.name.to_s.green} deployment for server #{server.name} failed")
|
59
|
-
|
60
|
-
exit 1 if result.exit_code != 0
|
61
68
|
@logger.info("Container deployment to #{server.user}@#{server.host} finished: #{container.name.to_s.green}")
|
62
69
|
|
63
70
|
deploy_context.close_session
|
@@ -9,8 +9,7 @@ class Indocker::ImagesCompiler
|
|
9
9
|
build_context = Indocker::BuildContext.new(
|
10
10
|
configuration: configuration,
|
11
11
|
build_server: nil,
|
12
|
-
logger: @logger
|
13
|
-
global_logger: Indocker.global_logger
|
12
|
+
logger: @logger
|
14
13
|
)
|
15
14
|
|
16
15
|
image_compiler = Indocker::Images::ImageCompiler.new
|
data/lib/indocker/ssh_session.rb
CHANGED
@@ -37,11 +37,27 @@ class Indocker::SshSession
|
|
37
37
|
!@ssh
|
38
38
|
end
|
39
39
|
|
40
|
-
def exec!(command)
|
41
|
-
if
|
40
|
+
def exec!(command, on_stdout: nil, on_stderr: nil)
|
41
|
+
if local?
|
42
|
+
exec_locally!(command)
|
43
|
+
else
|
44
|
+
exec_remotely!(command, on_stdout: on_stdout, on_stderr: on_stderr)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def close
|
49
|
+
if @ssh
|
50
|
+
@ssh.close
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def exec_locally!(command)
|
42
56
|
res = Indocker::Shell.command_with_result(command, @logger, skip_logging: false)
|
43
57
|
ExecResult.new(res.stdout, '', res.exit_status, nil)
|
44
|
-
|
58
|
+
end
|
59
|
+
|
60
|
+
def exec_remotely!(command, on_stdout:, on_stderr:)
|
45
61
|
if Indocker.export_command
|
46
62
|
command = "#{Indocker.export_command} && #{command}"
|
47
63
|
end
|
@@ -62,10 +78,12 @@ class Indocker::SshSession
|
|
62
78
|
|
63
79
|
channel.on_data do |ch,data|
|
64
80
|
stdout_data += data
|
81
|
+
on_stdout.call(data) if on_stdout
|
65
82
|
end
|
66
83
|
|
67
84
|
channel.on_extended_data do |ch,type,data|
|
68
85
|
stderr_data += data
|
86
|
+
on_stderr.call(data) if on_stderr
|
69
87
|
end
|
70
88
|
|
71
89
|
channel.on_request('exit-status') do |ch,data|
|
@@ -82,11 +100,4 @@ class Indocker::SshSession
|
|
82
100
|
|
83
101
|
ExecResult.new(stdout_data, stderr_data, exit_code, exit_signal)
|
84
102
|
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def close
|
88
|
-
if @ssh
|
89
|
-
@ssh.close
|
90
|
-
end
|
91
|
-
end
|
92
103
|
end
|
data/lib/indocker/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-08-
|
12
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -88,9 +88,16 @@ files:
|
|
88
88
|
- example/indocker/bin/remote/compile
|
89
89
|
- example/indocker/bin/remote/run
|
90
90
|
- example/indocker/bin/utils/configurations.rb
|
91
|
-
- example/indocker/bounded_contexts/shared/
|
92
|
-
- example/indocker/bounded_contexts/shared/
|
93
|
-
- example/indocker/bounded_contexts/shared/
|
91
|
+
- example/indocker/bounded_contexts/shared/bad_container_build/Dockerfile
|
92
|
+
- example/indocker/bounded_contexts/shared/bad_container_build/container.rb
|
93
|
+
- example/indocker/bounded_contexts/shared/bad_container_build/image.rb
|
94
|
+
- example/indocker/bounded_contexts/shared/bad_container_start/Dockerfile
|
95
|
+
- example/indocker/bounded_contexts/shared/bad_container_start/build_context/bin/run
|
96
|
+
- example/indocker/bounded_contexts/shared/bad_container_start/container.rb
|
97
|
+
- example/indocker/bounded_contexts/shared/bad_container_start/image.rb
|
98
|
+
- example/indocker/bounded_contexts/shared/good_container/Dockerfile
|
99
|
+
- example/indocker/bounded_contexts/shared/good_container/container.rb
|
100
|
+
- example/indocker/bounded_contexts/shared/good_container/image.rb
|
94
101
|
- example/indocker/bounded_contexts/shared/ruby/Dockerfile
|
95
102
|
- example/indocker/bounded_contexts/shared/ruby/container.rb
|
96
103
|
- example/indocker/bounded_contexts/shared/ruby/image.rb
|
@@ -156,7 +163,6 @@ files:
|
|
156
163
|
- lib/indocker/server.rb
|
157
164
|
- lib/indocker/server_pool.rb
|
158
165
|
- lib/indocker/shell.rb
|
159
|
-
- lib/indocker/ssh_result_logger.rb
|
160
166
|
- lib/indocker/ssh_session.rb
|
161
167
|
- lib/indocker/version.rb
|
162
168
|
- lib/indocker/volume_helper.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class Indocker::SshResultLogger
|
2
|
-
def initialize(logger)
|
3
|
-
@logger = logger
|
4
|
-
end
|
5
|
-
|
6
|
-
def log(result, error_message)
|
7
|
-
if result.exit_code == 0
|
8
|
-
puts result.stdout_data
|
9
|
-
else
|
10
|
-
@logger.error(error_message)
|
11
|
-
puts result.stdout_data
|
12
|
-
|
13
|
-
result.stderr_data.to_s.split("\n").each do |line|
|
14
|
-
@logger.error(line)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|