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,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Indocker::ImageDockerfileBuilder do
|
4
|
-
subject { ioc.image_dockerfile_builder }
|
5
|
-
|
6
|
-
describe '#build' do
|
7
|
-
let(:from_directive) { Indocker::ImageDirectives::From.new('ruby-alpine:latest') }
|
8
|
-
let(:workdir_directive) { Indocker::ImageDirectives::Workdir.new('/app') }
|
9
|
-
let(:env_file_directive) {
|
10
|
-
Indocker::ImageDirectives::EnvFile.new(
|
11
|
-
File.expand_path(File.join(__dir__, '../../fixtures/spec.env'))
|
12
|
-
)
|
13
|
-
}
|
14
|
-
|
15
|
-
it 'generates valid dockerfile' do
|
16
|
-
expect(
|
17
|
-
subject.build(from_directive, workdir_directive, env_file_directive)
|
18
|
-
).to eq(
|
19
|
-
"FROM ruby-alpine:latest\n" <<
|
20
|
-
"WORKDIR /app\n" <<
|
21
|
-
"ENV RUBY_ENV=development RAILS_ENV=development"
|
22
|
-
)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Indocker::ImageEvaluator' do
|
4
|
-
subject { ioc.image_evaluator }
|
5
|
-
let(:context) { Indocker::DSLContext.new(build_dir: 'some/path') }
|
6
|
-
|
7
|
-
before do
|
8
|
-
Indocker.define_partial 'example_partial' do
|
9
|
-
set_arg(:wait_connection, true)
|
10
|
-
set_arg(:notification_enabled, true)
|
11
|
-
|
12
|
-
before_build do
|
13
|
-
docker_cp 'yet_anoter_helper_container' do
|
14
|
-
copy '.' => '.'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
run "echo '#{wait_connection}'"
|
19
|
-
run "echo '#{notification_enabled}'"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'directives list' do
|
24
|
-
let(:example_image_definition) do
|
25
|
-
Proc.new do
|
26
|
-
set_arg(:environment, :stading)
|
27
|
-
set_arg(:server, :development)
|
28
|
-
|
29
|
-
before_build do
|
30
|
-
docker_cp 'helper_container' do
|
31
|
-
copy '.' => '.'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
from 'ruby:2.3.1'
|
36
|
-
|
37
|
-
partial 'example_partial', wait_connection: false, notification_enabled: true
|
38
|
-
|
39
|
-
workdir '/app'
|
40
|
-
|
41
|
-
run "echo 'Hello World'"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
let(:directives) { subject.evaluate(context, &example_image_definition) }
|
46
|
-
|
47
|
-
it 'returns array of directives' do
|
48
|
-
expect(directives).to be_a(Array)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'returns valid count of directives' do
|
52
|
-
expect(directives.size).to eq(7)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'rerurns proper directives classes' do
|
56
|
-
expect(directives[0]).to be_a(Indocker::ImageDirectives::DockerCp)
|
57
|
-
expect(directives[1]).to be_a(Indocker::ImageDirectives::From)
|
58
|
-
expect(directives[2]).to be_a(Indocker::ImageDirectives::DockerCp)
|
59
|
-
expect(directives[3]).to be_a(Indocker::ImageDirectives::Run)
|
60
|
-
expect(directives[4]).to be_a(Indocker::ImageDirectives::Run)
|
61
|
-
expect(directives[5]).to be_a(Indocker::ImageDirectives::Workdir)
|
62
|
-
expect(directives[6]).to be_a(Indocker::ImageDirectives::Run)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'with partial with options' do
|
67
|
-
let(:image_with_partial_definition) {
|
68
|
-
Proc.new do
|
69
|
-
partial :partial_directive, some_arg: 'some_arg_value'
|
70
|
-
end
|
71
|
-
}
|
72
|
-
|
73
|
-
before(:all) do
|
74
|
-
Indocker.define_partial :partial_directive do
|
75
|
-
run "echo #{some_arg}"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'generates valid dockerfile' do
|
80
|
-
partial_directive = subject.evaluate(context, &image_with_partial_definition).first
|
81
|
-
|
82
|
-
expect(partial_directive.to_s).to eq(%q(RUN echo some_arg_value))
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(__dir__)
|
3
|
-
|
4
|
-
require 'indocker'
|
5
|
-
require 'fileutils'
|
6
|
-
require 'byebug'
|
7
|
-
|
8
|
-
SmartIoC::Container.get_instance.set_extra_context_for_package(:indocker, :test)
|
9
|
-
SmartIoC.set_load_proc do |location|
|
10
|
-
require(location)
|
11
|
-
end
|
12
|
-
|
13
|
-
ioc.config.build_dir Pathname.new File.expand_path(File.join(__dir__, '../tmp/build'))
|
14
|
-
ioc.config.git.cache_dir Pathname.new File.expand_path(File.join(__dir__, '../tmp/cache'))
|
15
|
-
|
16
|
-
ioc.config.docker.registry(:localhost) { serveraddress 'http://localhost:1000' }
|
17
|
-
|
18
|
-
RSpec.configure do |config|
|
19
|
-
config.expect_with :rspec do |expectations|
|
20
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
21
|
-
end
|
22
|
-
|
23
|
-
config.mock_with :rspec
|
24
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
25
|
-
|
26
|
-
config.after(:all) { truncate_docker_items }
|
27
|
-
end
|
28
|
-
|
29
|
-
def ensure_exists(file)
|
30
|
-
expect(File.exists?(file)).to be true
|
31
|
-
end
|
32
|
-
|
33
|
-
def ensure_content(file, content)
|
34
|
-
expect(File.read(file)).to match(content)
|
35
|
-
end
|
36
|
-
|
37
|
-
def truncate_docker_items
|
38
|
-
ioc.docker_api.delete_containers_where { |container| container.refresh!.info['Config']['Image'] =~ /^indocker/ }
|
39
|
-
ioc.docker_api.delete_containers_where { |container| container.refresh!.info['Names'].grep(/^\/indocker/).any? }
|
40
|
-
ioc.docker_api.delete_images_where { |image| image.info['RepoTags'].grep(/^indocker/).any? }
|
41
|
-
ioc.docker_api.delete_networks_where { |network| network.info['Name'] =~ /^indocker/ }
|
42
|
-
ioc.docker_api.delete_volumes_where { |volume| volume.info['Name'] =~ /^indocker/ }
|
43
|
-
|
44
|
-
ioc.image_metadata_repository.clear
|
45
|
-
ioc.container_metadata_repository.clear
|
46
|
-
ioc.partial_metadata_repository.clear
|
47
|
-
ioc.network_metadata_repository.clear
|
48
|
-
ioc.volume_metadata_repository.clear
|
49
|
-
|
50
|
-
ioc.logger.clear
|
51
|
-
|
52
|
-
FileUtils.rm_rf(Dir.glob(File.join(__dir__, '../tmp/*')))
|
53
|
-
end
|
54
|
-
|
55
|
-
def set_local_registry
|
56
|
-
Indocker.define_image :registry do
|
57
|
-
from 'registry:latest'
|
58
|
-
end
|
59
|
-
|
60
|
-
Indocker.define_container :indocker_registry do
|
61
|
-
use images.find_by_repo(:registry)
|
62
|
-
env 'REGISTRY_STORAGE_DELETE_ENABLED=true'
|
63
|
-
ports '5000:1000'
|
64
|
-
end
|
65
|
-
|
66
|
-
ioc.image_builder.build('registry')
|
67
|
-
ioc.container_manager.run('indocker_registry')
|
68
|
-
end
|