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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8c37678a3d0b00e17c7e819b8565f0a4bb9330351a66711da35ab2a4fb6681e
4
- data.tar.gz: dc921c4c6839a9b31392a8373f1231c359261d8759eab8566934a221ddcb9d14
3
+ metadata.gz: d9667ebbc4e293dd51830ec7cae6c57455fe1b59b09722e094d76fa934564001
4
+ data.tar.gz: 4912748b481273ba9cc7a69e11698ebfc14cd01d942550bb7f67f014df0b1a46
5
5
  SHA512:
6
- metadata.gz: 78e90ff4a4970faa4e98b968da758e11fe8bcfd391a68f38c9c1c16210b09dbd93c6801e35873e2fa2fc5348af6e6467b3dfb299d4e3e879ef16391f43730504
7
- data.tar.gz: f585568265e524e2061bd3e8aab6330c8d4c0a0379ee6a0f4a05ad82dfe6089cbd1624205c98cbfb2df98af80ac81671289e51502f0f1fe45b1fdee1473e605f
6
+ metadata.gz: 553570ec945812578c4a3cfc1744e5455c8e18e584cc2bb0bed4f70227d751329d147c04d07858f0bd26390f3725eb7bed2ce6f5fab4e34ee3731e065cc54499
7
+ data.tar.gz: f1b46f64d4be12e0d62de23623fc3aac49fc0f10246effe8868fde2d9721d6105776ca7d06edd3e8e9d368352882125720915ca81ab2952e0e1feecd0eab51e3
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- indocker (0.1.3)
4
+ indocker (0.1.7)
5
5
  net-ssh
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  diff-lcs (1.3)
11
- net-ssh (5.2.0)
11
+ net-ssh (6.1.0)
12
12
  rake (10.5.0)
13
13
  rspec (3.9.0)
14
14
  rspec-core (~> 3.9.0)
@@ -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: false,
12
- force_restart: false,
13
- skip_tags: [],
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: 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],
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
  )
@@ -318,21 +318,26 @@ module Indocker
318
318
  builder
319
319
  end
320
320
 
321
- def deploy(containers: [], skip_tags: [], tags: [], skip_dependent: false, skip_containers: [], servers: [], skip_build: false, force_restart: false, skip_force_restart: [], auto_confirm: false, require_confirmation: 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: configuration,
326
- deploy_containers: containers,
327
- deploy_tags: tags,
328
- skip_dependent: skip_dependent,
329
- skip_containers: skip_containers,
330
- servers: servers,
331
- skip_build: skip_build,
332
- force_restart: force_restart,
333
- skip_tags: skip_tags,
334
- skip_force_restart: skip_force_restart,
335
- auto_confirm: auto_confirm,
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:, auto_confirm:, require_confirmation:)
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: build_servers,
60
- deploy_servers: deploy_servers,
61
- env_files: configuration.env_files.keys,
62
- repositories: configuration.repositories.keys,
63
- force_restart: force_restart,
64
- skip_build: skip_build,
65
- containers: containers,
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 += sync_env_files(deploy_servers, configuration.env_files)
74
- remote_operations += pull_repositories(clonner, build_servers, configuration.repositories)
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(configuration, deployer, build_context_pool, container, containers, skip_build, force_restart, skip_force_restart)
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, containers, skip_build, force_restart, skip_force_restart)
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(configuration, deployer, build_context_pool, container, containers, skip_build, force_restart, skip_force_restart)
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
- deployer.deploy(container, force_restart, skip_force_restart, @progress)
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
- session = Indocker::SshSession.new(
384
- host: server.host,
385
- user: server.user,
386
- port: server.port,
387
- logger: @logger
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
- @logger.info("Pulling git artifact #{artifact.name.to_s.green} for #{server.user}@#{server.host}")
391
- result = clonner.clone(session, artifact.repository)
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
- if result.exit_code != 0
394
- @logger.error("Artifact repository :#{artifact.repository.name} was not clonned")
395
- @logger.error(result.stderr_data)
396
- exit 1
397
- end
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
- source_path = File.join(artifact.repository.clone_path, artifact.source_path)
400
- result = session.exec!("mkdir -p #{artifact.target_path}")
401
- result = session.exec!("cp -r #{source_path} #{artifact.target_path}")
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
- if !result.success?
404
- @logger.error(result.stdout_data)
405
- @logger.error(result.stderr_data)
406
- exit 1
407
- end
436
+ if !result.success?
437
+ @logger.error(result.stdout_data)
438
+ @logger.error(result.stderr_data)
439
+ exit 1
440
+ end
408
441
 
409
- @progress.finish_syncing_artifact(server, artifact)
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.error("build arg '#{format_arg(name)}' is not defined#{@container ? " for container :#{@container.name}" : ""}")
18
- Indocker.logger.error("available args: #{@context_args.inspect}")
19
- exit 1
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 = 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
@@ -17,4 +17,14 @@ class Indocker::Server
17
17
  super
18
18
  end
19
19
  end
20
+
21
+ def synchronize(&block)
22
+ semaphore.synchronize do
23
+ block.call if block_given?
24
+ end
25
+ end
26
+
27
+ def semaphore
28
+ @semaphore ||= Mutex.new
29
+ end
20
30
  end
@@ -1,3 +1,3 @@
1
1
  module Indocker
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.8"
3
3
  end
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.3
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-06-03 00:00:00.000000000 Z
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.8
177
+ rubygems_version: 3.0.3
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: Docker Containers Deployment