indocker 0.1.12 → 0.1.17

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/Gemfile +0 -1
  4. data/Gemfile.lock +8 -2
  5. data/example/indocker/bin/deploy +3 -6
  6. data/example/indocker/bin/remote/compile +2 -6
  7. data/example/indocker/bin/remote/run +2 -6
  8. data/example/indocker/bounded_contexts/{shared → bad_containers}/bad_container_build/Dockerfile +0 -0
  9. data/example/indocker/bounded_contexts/{shared → bad_containers}/bad_container_build/container.rb +2 -1
  10. data/example/indocker/bounded_contexts/{shared → bad_containers}/bad_container_build/image.rb +0 -0
  11. data/example/indocker/bounded_contexts/{shared → bad_containers}/bad_container_start/Dockerfile +0 -0
  12. data/example/indocker/bounded_contexts/{shared → bad_containers}/bad_container_start/build_context/bin/run +0 -0
  13. data/example/indocker/bounded_contexts/{shared → bad_containers}/bad_container_start/container.rb +2 -1
  14. data/example/indocker/bounded_contexts/{shared → bad_containers}/bad_container_start/image.rb +0 -0
  15. data/example/indocker/bounded_contexts/good_containers/daemon_container/Dockerfile +1 -0
  16. data/example/indocker/bounded_contexts/good_containers/daemon_container/container.rb +6 -0
  17. data/example/indocker/bounded_contexts/good_containers/daemon_container/image.rb +4 -0
  18. data/example/indocker/bounded_contexts/good_containers/dependency_container/Dockerfile +1 -0
  19. data/example/indocker/bounded_contexts/good_containers/dependency_container/container.rb +6 -0
  20. data/example/indocker/bounded_contexts/good_containers/dependency_container/image.rb +4 -0
  21. data/example/indocker/bounded_contexts/good_containers/good_container/Dockerfile +3 -0
  22. data/example/indocker/bounded_contexts/good_containers/good_container/build_context/example_file.txt +2 -0
  23. data/example/indocker/bounded_contexts/good_containers/good_container/container.rb +10 -0
  24. data/example/indocker/bounded_contexts/good_containers/good_container/image.rb +4 -0
  25. data/example/indocker/bounded_contexts/shared/{good_container → parent_image}/Dockerfile +1 -1
  26. data/example/indocker/bounded_contexts/shared/parent_image/image.rb +3 -0
  27. data/example/indocker/bounded_contexts/shared/ruby/container.rb +2 -1
  28. data/example/indocker/configurations/external.rb +11 -1
  29. data/example/indocker/env_files/development_env.env +1 -0
  30. data/example/indocker/infrastructure/artifacts.rb +26 -0
  31. data/example/indocker/infrastructure/env_files.rb +6 -0
  32. data/example/indocker/setup.rb +3 -1
  33. data/indocker.gemspec +1 -0
  34. data/lib/indocker.rb +42 -20
  35. data/lib/indocker/artifacts/base.rb +26 -0
  36. data/lib/indocker/artifacts/dto/file_dto.rb +8 -0
  37. data/lib/indocker/artifacts/git.rb +17 -5
  38. data/lib/indocker/artifacts/remote.rb +17 -0
  39. data/lib/indocker/artifacts/services/synchronizer.rb +59 -0
  40. data/lib/indocker/build_context.rb +6 -41
  41. data/lib/indocker/build_context_helper.rb +1 -1
  42. data/lib/indocker/container_deployer.rb +12 -23
  43. data/lib/indocker/crontab_redeploy_rules_builder.rb +6 -6
  44. data/lib/indocker/deploy_context.rb +4 -32
  45. data/lib/indocker/deployment_checker.rb +4 -2
  46. data/lib/indocker/docker_run_args.rb +2 -2
  47. data/lib/indocker/images/image_compiler.rb +0 -1
  48. data/lib/indocker/{configuration_deployer.rb → launchers/configuration_deployer.rb} +66 -113
  49. data/lib/indocker/{container_runner.rb → launchers/container_runner.rb} +2 -3
  50. data/lib/indocker/launchers/dto/remote_operation_dto.rb +10 -0
  51. data/lib/indocker/{images_compiler.rb → launchers/images_compiler.rb} +1 -2
  52. data/lib/indocker/{network.rb → networks/network.rb} +1 -1
  53. data/lib/indocker/{network_helper.rb → networks/network_helper.rb} +1 -1
  54. data/lib/indocker/repositories/cloner.rb +73 -0
  55. data/lib/indocker/server_pools/build_server_connection.rb +15 -0
  56. data/lib/indocker/server_pools/build_server_pool.rb +40 -0
  57. data/lib/indocker/server_pools/deploy_server_connection.rb +17 -0
  58. data/lib/indocker/server_pools/deploy_server_pool.rb +41 -0
  59. data/lib/indocker/server_pools/server_connection.rb +37 -0
  60. data/lib/indocker/version.rb +1 -1
  61. data/lib/indocker/{volume_helper.rb → volumes/volume_helper.rb} +1 -1
  62. metadata +56 -24
  63. data/example/indocker/bounded_contexts/shared/good_container/container.rb +0 -5
  64. data/example/indocker/bounded_contexts/shared/good_container/image.rb +0 -3
  65. data/example/spec/indocker_spec.rb +0 -39
  66. data/example/spec/spec_helper.rb +0 -39
  67. data/lib/indocker/build_context_pool.rb +0 -42
  68. data/lib/indocker/configurations/formatters/stdout.rb +0 -36
  69. data/lib/indocker/repositories/clonner.rb +0 -17
  70. data/lib/indocker/server_pool.rb +0 -38
@@ -1,5 +0,0 @@
1
- Indocker
2
- .define_container(:good_container)
3
- .tags('good_container', 'console=true')
4
- .image(:good_container)
5
- .networks(:app_net)
@@ -1,3 +0,0 @@
1
- Indocker
2
- .define_image(:good_container)
3
- .registry(:default)
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Indocker do
4
- it "has a version number" do
5
- expect(Indocker::VERSION).not_to be nil
6
- end
7
-
8
- describe "successful deployment" do
9
- it "doesn't raise any error" do
10
- expect{
11
- launch_deployment(containers: [:good_container])
12
- }.to_not raise_error
13
- end
14
-
15
- it "shows a message about successful deploy" do
16
- allow(Indocker.global_logger).to receive(:info).at_least(:once)
17
-
18
- launch_deployment(containers: [:good_container])
19
-
20
- expect(Indocker.global_logger).to have_received(:info).at_least(:once).with(/Deployment finished/)
21
- end
22
- end
23
-
24
- describe "failed build" do
25
- it "exits with an error" do
26
- expect{
27
- launch_deployment(containers: [:bad_container_build])
28
- }.to raise_error(SystemExit)
29
- end
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
39
- end
@@ -1,39 +0,0 @@
1
- require "bundler/setup"
2
- require "indocker"
3
- require "pry"
4
-
5
- RSpec.configure do |config|
6
- # Enable flags like --only-failures and --next-failure
7
- config.example_status_persistence_file_path = ".rspec_status"
8
-
9
- # Disable RSpec exposing methods globally on `Module` and `main`
10
- config.disable_monkey_patching!
11
-
12
- config.expect_with :rspec do |c|
13
- c.syntax = :expect
14
- end
15
- end
16
-
17
- def launch_deployment(options = {})
18
- require_relative '../indocker/bin/utils/configurations'
19
-
20
- Indocker.set_configuration_name(options[:configuration] || "external")
21
- require_relative '../indocker/setup'
22
-
23
- Indocker.set_log_level(options[:debug] ? Logger::DEBUG : Logger::INFO)
24
-
25
- Indocker.deploy(
26
- containers: options[:containers] || [],
27
- tags: options[:tags] || [],
28
- skip_containers: options[:skip_containers] || [],
29
- skip_dependent: !!options[:skip_dependent],
30
- servers: options[:servers] || [],
31
- skip_build: options[:skip_build],
32
- skip_deploy: options[:skip_deploy],
33
- force_restart: options[:force_restart],
34
- skip_tags: options[:skip_tags] || [],
35
- skip_force_restart: options[:skip_force_restart] || [],
36
- auto_confirm: !!options[:auto_confirm],
37
- require_confirmation: !!options[:require_confirmation],
38
- )
39
- end
@@ -1,42 +0,0 @@
1
- class Indocker::BuildContextPool
2
- def initialize(configuration:, logger:, global_logger:)
3
- @logger = logger
4
- @configuration = configuration
5
- @global_logger = global_logger
6
-
7
- @contexts = configuration.build_servers.map do |build_server|
8
- Indocker::BuildContext.new(
9
- logger: @logger,
10
- configuration: configuration,
11
- build_server: build_server,
12
- global_logger: @global_logger,
13
- )
14
- end
15
- end
16
-
17
- def create_sessions!
18
- @contexts.each(&:create_session!)
19
- end
20
-
21
- def get
22
- context = nil
23
-
24
- loop do
25
- context = @contexts.detect {|c| !c.busy?}
26
- sleep(0.1)
27
- break if context
28
- end
29
-
30
- context
31
- end
32
-
33
- def each(&proc)
34
- @contexts.each(&proc)
35
- end
36
-
37
- def close_sessions
38
- @contexts.each(&:close_session)
39
- rescue => e
40
- @logger.error("error during session close: #{e.inspect}")
41
- end
42
- end
@@ -1,36 +0,0 @@
1
- class Indocker::Configurations::Formatters::Stdout
2
- def print(configuration)
3
- c = configuration
4
- <<~EOS
5
- Name: #{c.name}
6
-
7
- Repositories: {
8
- #{c.repositories.map do |alias_name, repository|
9
- " #{alias_name}: #{repository.inspect}"
10
- end.join("\n")}
11
- }
12
-
13
- Registries: {
14
- #{c.registries.map do |alias_name, registry|
15
- " #{alias_name}: #{registry.inspect}"
16
- end.join("\n")}
17
- }
18
-
19
- Servers: {
20
- #{c.servers.map do |alias_name, server|
21
- " #{alias_name}: #{server.inspect}"
22
- end.join("\n")}
23
- }
24
-
25
- Build Servers: [
26
- #{c.build_servers.map do |build_server|
27
- " #{build_server.inspect}"
28
- end.join("\n")}
29
- ]
30
-
31
- Tags: #{c.tags.inspect}
32
-
33
- Global build args: #{c.global_build_args.inspect}
34
- EOS
35
- end
36
- end
@@ -1,17 +0,0 @@
1
- require 'net/ssh'
2
-
3
- class Indocker::Repositories::Clonner
4
- def initialize(configuration, logger)
5
- @configuration = configuration
6
- @logger = logger
7
- end
8
-
9
- def clone(session, repository)
10
- raise ArgumenError.new("only git repositories should be clonned") if !repository.is_git?
11
-
12
- session.exec!("rm -rf #{repository.clone_path} && mkdir -p #{repository.clone_path}")
13
-
14
- git_command = "git clone -b #{repository.branch} --depth 1 #{repository.remote_url} #{repository.clone_path}"
15
- session.exec!("ssh-agent bash -c 'ssh-add ~/.ssh/#{repository.ssh_key}; #{git_command}'")
16
- end
17
- end
@@ -1,38 +0,0 @@
1
- class Indocker::ServerPool
2
- def initialize(configuration:, logger:)
3
- @logger = logger
4
- @configuration = configuration
5
-
6
- @contexts = configuration.servers.map do |server|
7
- Indocker::DeployContext.new(
8
- logger: @logger,
9
- configuration: configuration,
10
- server: server,
11
- )
12
- end
13
- end
14
-
15
- def create_sessions!
16
- @contexts.each(&:create_session!)
17
- end
18
-
19
- # NOTE: get is a bad name here, because we create a new connection.
20
- # TODO: why we create a new connection here?
21
- def get(server)
22
- context = Indocker::DeployContext.new(
23
- logger: @logger,
24
- configuration: @configuration,
25
- server: server,
26
- )
27
- context.create_session!
28
- context
29
- end
30
-
31
- def each(&proc)
32
- @contexts.each(&proc)
33
- end
34
-
35
- def close_sessions
36
- @contexts.each(&:close_session)
37
- end
38
- end