indocker 0.1.3 → 0.1.8
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/example/indocker/bin/deploy +19 -13
- data/lib/indocker.rb +17 -12
- data/lib/indocker/configuration_deployer.rb +71 -37
- data/lib/indocker/context_args.rb +4 -3
- data/lib/indocker/deployment_progress.rb +7 -2
- data/lib/indocker/server.rb +10 -0
- data/lib/indocker/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9667ebbc4e293dd51830ec7cae6c57455fe1b59b09722e094d76fa934564001
|
4
|
+
data.tar.gz: 4912748b481273ba9cc7a69e11698ebfc14cd01d942550bb7f67f014df0b1a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 553570ec945812578c4a3cfc1744e5455c8e18e584cc2bb0bed4f70227d751329d147c04d07858f0bd26390f3725eb7bed2ce6f5fab4e34ee3731e065cc54499
|
7
|
+
data.tar.gz: f1b46f64d4be12e0d62de23623fc3aac49fc0f10246effe8868fde2d9721d6105776ca7d06edd3e8e9d368352882125720915ca81ab2952e0e1feecd0eab51e3
|
data/Gemfile.lock
CHANGED
data/example/indocker/bin/deploy
CHANGED
@@ -8,9 +8,10 @@ configurations = list_configurations(File.expand_path(File.join(__dir__, '../con
|
|
8
8
|
ARGV << '-h' if ARGV.empty?
|
9
9
|
|
10
10
|
options = {
|
11
|
-
skip_build:
|
12
|
-
|
13
|
-
|
11
|
+
skip_build: false,
|
12
|
+
skip_deploy: false,
|
13
|
+
force_restart: false,
|
14
|
+
skip_tags: [],
|
14
15
|
skip_force_restart: [],
|
15
16
|
}
|
16
17
|
|
@@ -61,6 +62,10 @@ OptionParser.new do |opts|
|
|
61
62
|
options[:skip_build] = true
|
62
63
|
end
|
63
64
|
|
65
|
+
opts.on("-b", "--skip-deploy", "Skip image deploy") do |val|
|
66
|
+
options[:skip_deploy] = true
|
67
|
+
end
|
68
|
+
|
64
69
|
opts.on("-y", "--auto-confirm", "Automatically confirm deployment") do |val|
|
65
70
|
options[:auto_confirm] = true
|
66
71
|
end
|
@@ -106,15 +111,16 @@ Indocker.set_configuration_name(options[:configuration])
|
|
106
111
|
require_relative '../setup'
|
107
112
|
|
108
113
|
Indocker.deploy(
|
109
|
-
containers:
|
110
|
-
tags:
|
111
|
-
skip_containers:
|
112
|
-
skip_dependent:
|
113
|
-
servers:
|
114
|
-
skip_build:
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
containers: options[:containers] || [],
|
115
|
+
tags: options[:tags] || [],
|
116
|
+
skip_containers: options[:skip_containers] || [],
|
117
|
+
skip_dependent: !!options[:skip_dependent],
|
118
|
+
servers: options[:servers] || [],
|
119
|
+
skip_build: options[:skip_build],
|
120
|
+
skip_deploy: options[:skip_deploy],
|
121
|
+
force_restart: options[:force_restart],
|
122
|
+
skip_tags: options[:skip_tags] || [],
|
123
|
+
skip_force_restart: options[:skip_force_restart] || [],
|
124
|
+
auto_confirm: !!options[:auto_confirm],
|
119
125
|
require_confirmation: !!options[:require_confirmation],
|
120
126
|
)
|
data/lib/indocker.rb
CHANGED
@@ -318,21 +318,26 @@ module Indocker
|
|
318
318
|
builder
|
319
319
|
end
|
320
320
|
|
321
|
-
def deploy(containers: [], skip_tags: [], tags: [], skip_dependent: false,
|
321
|
+
def deploy(containers: [], skip_tags: [], tags: [], skip_dependent: false,
|
322
|
+
skip_containers: [], servers: [], skip_build: false, skip_deploy: false,
|
323
|
+
force_restart: false, skip_force_restart: [], auto_confirm: false,
|
324
|
+
require_confirmation: false)
|
325
|
+
|
322
326
|
Indocker::ConfigurationDeployer
|
323
327
|
.new(Indocker.logger)
|
324
328
|
.run(
|
325
|
-
configuration:
|
326
|
-
deploy_containers:
|
327
|
-
deploy_tags:
|
328
|
-
skip_dependent:
|
329
|
-
skip_containers:
|
330
|
-
servers:
|
331
|
-
skip_build:
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
329
|
+
configuration: configuration,
|
330
|
+
deploy_containers: containers,
|
331
|
+
deploy_tags: tags,
|
332
|
+
skip_dependent: skip_dependent,
|
333
|
+
skip_containers: skip_containers,
|
334
|
+
servers: servers,
|
335
|
+
skip_build: skip_build,
|
336
|
+
skip_deploy: skip_deploy,
|
337
|
+
force_restart: force_restart,
|
338
|
+
skip_tags: skip_tags,
|
339
|
+
skip_force_restart: skip_force_restart,
|
340
|
+
auto_confirm: auto_confirm,
|
336
341
|
require_confirmation: require_confirmation,
|
337
342
|
)
|
338
343
|
end
|
@@ -18,7 +18,8 @@ class Indocker::ConfigurationDeployer
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def run(configuration:, deploy_containers:, skip_tags:, deploy_tags:, skip_dependent:,
|
21
|
-
skip_containers:, servers:, skip_build:, force_restart:, skip_force_restart:,
|
21
|
+
skip_containers:, servers:, skip_build:, skip_deploy:, force_restart:, skip_force_restart:,
|
22
|
+
auto_confirm:, require_confirmation:)
|
22
23
|
build_context_pool = nil
|
23
24
|
deployer = nil
|
24
25
|
|
@@ -31,6 +32,10 @@ class Indocker::ConfigurationDeployer
|
|
31
32
|
@logger.warn("WARNING. Images build step will be skipped")
|
32
33
|
end
|
33
34
|
|
35
|
+
if skip_deploy
|
36
|
+
@logger.warn("WARNING. Images deploy step will be skipped")
|
37
|
+
end
|
38
|
+
|
34
39
|
preload_containers(configuration)
|
35
40
|
|
36
41
|
containers = find_deploy_containers(configuration, deploy_containers, deploy_tags, skip_dependent, skip_containers, servers, skip_tags, auto_confirm, require_confirmation)
|
@@ -56,30 +61,43 @@ class Indocker::ConfigurationDeployer
|
|
56
61
|
|
57
62
|
@progress.setup(
|
58
63
|
binaries_servers: servers,
|
59
|
-
build_servers:
|
60
|
-
deploy_servers:
|
61
|
-
env_files:
|
62
|
-
repositories:
|
63
|
-
force_restart:
|
64
|
-
skip_build:
|
65
|
-
|
64
|
+
build_servers: build_servers,
|
65
|
+
deploy_servers: deploy_servers,
|
66
|
+
env_files: configuration.env_files.keys,
|
67
|
+
repositories: configuration.repositories.keys,
|
68
|
+
force_restart: force_restart,
|
69
|
+
skip_build: skip_build,
|
70
|
+
skip_deploy: skip_deploy,
|
71
|
+
containers: containers,
|
66
72
|
artifact_servers: configuration.artifact_servers,
|
67
73
|
)
|
68
74
|
|
69
75
|
remote_operations = sync_indocker(servers)
|
76
|
+
wait_remote_operations(remote_operations)
|
70
77
|
|
78
|
+
remote_operations = sync_env_files(deploy_servers, configuration.env_files)
|
71
79
|
wait_remote_operations(remote_operations)
|
72
80
|
|
73
|
-
remote_operations
|
74
|
-
remote_operations
|
75
|
-
remote_operations += sync_artifacts(clonner, configuration.artifact_servers)
|
81
|
+
remote_operations = pull_repositories(clonner, build_servers, configuration.repositories)
|
82
|
+
wait_remote_operations(remote_operations)
|
76
83
|
|
84
|
+
remote_operations = sync_artifacts(clonner, configuration.artifact_servers)
|
77
85
|
wait_remote_operations(remote_operations)
|
78
86
|
|
79
87
|
update_crontab_redeploy_rules(configuration, build_servers.first)
|
80
88
|
|
81
89
|
containers.uniq.each do |container|
|
82
|
-
recursively_deploy_container(
|
90
|
+
recursively_deploy_container(
|
91
|
+
configuration,
|
92
|
+
deployer,
|
93
|
+
build_context_pool,
|
94
|
+
container,
|
95
|
+
containers,
|
96
|
+
skip_build,
|
97
|
+
skip_deploy,
|
98
|
+
force_restart,
|
99
|
+
skip_force_restart
|
100
|
+
)
|
83
101
|
end
|
84
102
|
|
85
103
|
Thread
|
@@ -283,9 +301,21 @@ class Indocker::ConfigurationDeployer
|
|
283
301
|
build_context.set_compiled(image)
|
284
302
|
end
|
285
303
|
|
286
|
-
def recursively_deploy_container(configuration, deployer, build_context_pool, container,
|
304
|
+
def recursively_deploy_container(configuration, deployer, build_context_pool, container,
|
305
|
+
containers, skip_build, skip_deploy, force_restart, skip_force_restart)
|
306
|
+
|
287
307
|
container.dependent_containers.each do |container|
|
288
|
-
recursively_deploy_container(
|
308
|
+
recursively_deploy_container(
|
309
|
+
configuration,
|
310
|
+
deployer,
|
311
|
+
build_context_pool,
|
312
|
+
container,
|
313
|
+
containers,
|
314
|
+
skip_build,
|
315
|
+
skip_deploy,
|
316
|
+
force_restart,
|
317
|
+
skip_force_restart
|
318
|
+
)
|
289
319
|
end
|
290
320
|
|
291
321
|
return if !containers.include?(container)
|
@@ -302,7 +332,9 @@ class Indocker::ConfigurationDeployer
|
|
302
332
|
|
303
333
|
@progress.finish_building_container(container)
|
304
334
|
|
305
|
-
|
335
|
+
if !skip_deploy
|
336
|
+
deployer.deploy(container, force_restart, skip_force_restart, @progress)
|
337
|
+
end
|
306
338
|
end
|
307
339
|
|
308
340
|
class RemoteOperation
|
@@ -380,33 +412,35 @@ class Indocker::ConfigurationDeployer
|
|
380
412
|
@progress.start_syncing_artifact(server, artifact)
|
381
413
|
|
382
414
|
thread = Thread.new do
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
415
|
+
server.synchronize do
|
416
|
+
session = Indocker::SshSession.new(
|
417
|
+
host: server.host,
|
418
|
+
user: server.user,
|
419
|
+
port: server.port,
|
420
|
+
logger: @logger
|
421
|
+
)
|
389
422
|
|
390
|
-
|
391
|
-
|
423
|
+
@logger.info("Pulling git artifact #{artifact.name.to_s.green} for #{server.user}@#{server.host}")
|
424
|
+
result = clonner.clone(session, artifact.repository)
|
392
425
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
426
|
+
if result.exit_code != 0
|
427
|
+
@logger.error("Artifact repository :#{artifact.repository.name} was not clonned")
|
428
|
+
@logger.error(result.stderr_data)
|
429
|
+
exit 1
|
430
|
+
end
|
398
431
|
|
399
|
-
|
400
|
-
|
401
|
-
|
432
|
+
source_path = File.join(artifact.repository.clone_path, artifact.source_path)
|
433
|
+
result = session.exec!("mkdir -p #{artifact.target_path}")
|
434
|
+
result = session.exec!("cp -r #{source_path} #{artifact.target_path}")
|
402
435
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
436
|
+
if !result.success?
|
437
|
+
@logger.error(result.stdout_data)
|
438
|
+
@logger.error(result.stderr_data)
|
439
|
+
exit 1
|
440
|
+
end
|
408
441
|
|
409
|
-
|
442
|
+
@progress.finish_syncing_artifact(server, artifact)
|
443
|
+
end
|
410
444
|
end
|
411
445
|
|
412
446
|
RemoteOperation.new(thread, server, :artifact_sync)
|
@@ -14,9 +14,10 @@ class Indocker::ContextArgs
|
|
14
14
|
end
|
15
15
|
|
16
16
|
value = @context_args.fetch(name) do
|
17
|
-
Indocker.logger.
|
18
|
-
Indocker.logger.
|
19
|
-
|
17
|
+
Indocker.logger.warn("build arg '#{format_arg(name)}' is not defined#{@container ? " for container :#{@container.name}" : ""}")
|
18
|
+
Indocker.logger.warn("available args: #{@context_args.inspect}")
|
19
|
+
|
20
|
+
nil
|
20
21
|
end
|
21
22
|
|
22
23
|
if value.is_a?(Hash)
|
@@ -70,9 +70,10 @@ class Indocker::DeploymentProgress
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def setup(binaries_servers:, build_servers:, deploy_servers:, env_files:, artifact_servers:,
|
73
|
-
repositories:, force_restart:, skip_build:, containers:)
|
73
|
+
repositories:, force_restart:, skip_build:, skip_deploy:, containers:)
|
74
74
|
@force_restart = force_restart
|
75
|
-
@skip_build
|
75
|
+
@skip_build = skip_build
|
76
|
+
@skip_deploy = skip_deploy
|
76
77
|
|
77
78
|
binaries_servers.each do |server|
|
78
79
|
@synced_binaries[server] = {
|
@@ -250,6 +251,10 @@ class Indocker::DeploymentProgress
|
|
250
251
|
@logger.info("Warning: Image build is skipped for all containers".purple)
|
251
252
|
end
|
252
253
|
|
254
|
+
if @skip_deploy
|
255
|
+
@logger.info("Warning: All container deployment is skipped".purple)
|
256
|
+
end
|
257
|
+
|
253
258
|
if @force_restart
|
254
259
|
@logger.info("Warning: All containers will be force restarted".purple)
|
255
260
|
end
|
data/lib/indocker/server.rb
CHANGED
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.8
|
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-
|
12
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
174
|
- !ruby/object:Gem::Version
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
|
-
rubygems_version: 3.0.
|
177
|
+
rubygems_version: 3.0.3
|
178
178
|
signing_key:
|
179
179
|
specification_version: 4
|
180
180
|
summary: Docker Containers Deployment
|