dapp 0.4.8 → 0.5.0

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/config/en/common.yml +1 -0
  3. data/config/en/net_status.yml +2 -2
  4. data/lib/dapp.rb +9 -2
  5. data/lib/dapp/application.rb +2 -5
  6. data/lib/dapp/application/path.rb +3 -3
  7. data/lib/dapp/build/stage/artifact.rb +35 -0
  8. data/lib/dapp/build/stage/base.rb +42 -20
  9. data/lib/dapp/build/stage/chef_cookbooks.rb +12 -2
  10. data/lib/dapp/build/stage/docker_instructions.rb +31 -0
  11. data/lib/dapp/build/stage/from.rb +5 -4
  12. data/lib/dapp/build/stage/infra_install.rb +6 -2
  13. data/lib/dapp/build/stage/infra_setup.rb +8 -0
  14. data/lib/dapp/build/stage/install.rb +8 -0
  15. data/lib/dapp/build/stage/mod/artifact.rb +16 -21
  16. data/lib/dapp/build/stage/mod/logging.rb +8 -2
  17. data/lib/dapp/build/stage/setup.rb +8 -0
  18. data/lib/dapp/build/stage/source_1.rb +4 -14
  19. data/lib/dapp/build/stage/source_1_archive.rb +2 -2
  20. data/lib/dapp/build/stage/source_1_archive_dependencies.rb +13 -0
  21. data/lib/dapp/build/stage/source_1_dependencies.rb +27 -0
  22. data/lib/dapp/build/stage/source_2.rb +3 -6
  23. data/lib/dapp/build/stage/source_2_dependencies.rb +17 -0
  24. data/lib/dapp/build/stage/source_3.rb +3 -13
  25. data/lib/dapp/build/stage/source_3_dependencies.rb +23 -0
  26. data/lib/dapp/build/stage/source_4.rb +2 -16
  27. data/lib/dapp/build/stage/source_4_dependencies.rb +27 -0
  28. data/lib/dapp/build/stage/source_5.rb +17 -16
  29. data/lib/dapp/build/stage/source_base.rb +17 -39
  30. data/lib/dapp/build/stage/source_dependencies_base.rb +28 -0
  31. data/lib/dapp/builder/base.rb +16 -0
  32. data/lib/dapp/builder/chef.rb +49 -29
  33. data/lib/dapp/builder/shell.rb +13 -4
  34. data/lib/dapp/cli.rb +1 -2
  35. data/lib/dapp/cli/build.rb +5 -5
  36. data/lib/dapp/cli/push.rb +0 -4
  37. data/lib/dapp/cli/run.rb +0 -3
  38. data/lib/dapp/config/artifact.rb +0 -23
  39. data/lib/dapp/controller.rb +9 -9
  40. data/lib/dapp/error/dappfile.rb +6 -0
  41. data/lib/dapp/git_artifact.rb +2 -2
  42. data/lib/dapp/image/argument.rb +2 -4
  43. data/lib/dapp/image/docker.rb +5 -0
  44. data/lib/dapp/image/stage.rb +4 -0
  45. data/lib/dapp/version.rb +2 -2
  46. metadata +10 -3
  47. data/lib/dapp/cli/metadata.rb +0 -18
  48. data/lib/dapp/cli/metadata/flush.rb +0 -22
@@ -8,8 +8,10 @@ module Dapp
8
8
  def log_build
9
9
  application.with_log_indent do
10
10
  application.log_info application.t(code: 'image.signature', data: { signature: image_name })
11
- log_image_info
12
- log_image_commands
11
+ unless empty?
12
+ log_image_info
13
+ log_image_commands unless ignore_log_commands?
14
+ end
13
15
  end if application.log? && application.log_verbose?
14
16
  end
15
17
 
@@ -41,6 +43,10 @@ module Dapp
41
43
  from_image.tagged? && !prev_stage.nil?
42
44
  end
43
45
 
46
+ def ignore_log_commands?
47
+ false
48
+ end
49
+
44
50
  def should_be_skipped?
45
51
  image.tagged? && !application.log_verbose? && application.cli_options[:introspect_stage].nil?
46
52
  end
@@ -8,6 +8,14 @@ module Dapp
8
8
  super
9
9
  end
10
10
 
11
+ def empty?
12
+ super && !application.builder.setup?
13
+ end
14
+
15
+ def dependencies
16
+ prev_stage.prev_stage.dependencies
17
+ end
18
+
11
19
  def image
12
20
  super do |image|
13
21
  application.builder.setup(image)
@@ -4,26 +4,16 @@ module Dapp
4
4
  # Source1
5
5
  class Source1 < SourceBase
6
6
  def initialize(application, next_stage)
7
- @prev_stage = Source1Archive.new(application, self)
7
+ @prev_stage = Source1Dependencies.new(application, self)
8
8
  super
9
9
  end
10
10
 
11
11
  def prev_source_stage
12
- prev_stage
12
+ dependencies_stage.prev_stage
13
13
  end
14
14
 
15
- protected
16
-
17
- def dependencies_checksum
18
- hashsum [super,
19
- install_dependencies_files_checksum,
20
- *application.builder.install_checksum]
21
- end
22
-
23
- private
24
-
25
- def install_dependencies_files_checksum
26
- @install_dependencies_files_checksum ||= dependencies_files_checksum(application.config._install_dependencies)
15
+ def next_source_stage
16
+ super.next_stage
27
17
  end
28
18
  end # Source1
29
19
  end # Stage
@@ -4,7 +4,7 @@ module Dapp
4
4
  # Source1Archive
5
5
  class Source1Archive < SourceBase
6
6
  def initialize(application, next_stage)
7
- @prev_stage = InfraInstall.new(application, self)
7
+ @prev_stage = Source1ArchiveDependencies.new(application, self)
8
8
  super
9
9
  end
10
10
 
@@ -13,7 +13,7 @@ module Dapp
13
13
  end
14
14
 
15
15
  def next_source_stage
16
- next_stage
16
+ next_stage.next_stage
17
17
  end
18
18
 
19
19
  protected
@@ -0,0 +1,13 @@
1
+ module Dapp
2
+ module Build
3
+ module Stage
4
+ # Source1ArchiveDependencies
5
+ class Source1ArchiveDependencies < SourceDependenciesBase
6
+ def initialize(application, next_stage)
7
+ @prev_stage = InfraInstall.new(application, self)
8
+ super
9
+ end
10
+ end # Source1ArchiveDependencies
11
+ end # Stage
12
+ end # Build
13
+ end # Dapp
@@ -0,0 +1,27 @@
1
+ module Dapp
2
+ module Build
3
+ module Stage
4
+ # Source1Dependencies
5
+ class Source1Dependencies < SourceDependenciesBase
6
+ def initialize(application, next_stage)
7
+ @prev_stage = Source1Archive.new(application, self)
8
+ super
9
+ end
10
+
11
+ def dependencies
12
+ [install_dependencies_files_checksum, application.builder.install_checksum]
13
+ end
14
+
15
+ def empty?
16
+ super || dependencies_empty?
17
+ end
18
+
19
+ private
20
+
21
+ def install_dependencies_files_checksum
22
+ @install_dependencies_files_checksum ||= dependencies_files_checksum(application.config._install_dependencies)
23
+ end
24
+ end # Source1Dependencies
25
+ end # Stage
26
+ end # Build
27
+ end # Dapp
@@ -4,15 +4,12 @@ module Dapp
4
4
  # Source2
5
5
  class Source2 < SourceBase
6
6
  def initialize(application, next_stage)
7
- @prev_stage = Install.new(application, self)
7
+ @prev_stage = Source2Dependencies.new(application, self)
8
8
  super
9
9
  end
10
10
 
11
- protected
12
-
13
- def dependencies_checksum
14
- hashsum [super,
15
- *application.builder.infra_setup_checksum]
11
+ def prev_source_stage
12
+ super.prev_stage
16
13
  end
17
14
  end # Source2
18
15
  end # Stage
@@ -0,0 +1,17 @@
1
+ module Dapp
2
+ module Build
3
+ module Stage
4
+ # Source2Dependencies
5
+ class Source2Dependencies < SourceDependenciesBase
6
+ def initialize(application, next_stage)
7
+ @prev_stage = Artifact.new(application, self)
8
+ super
9
+ end
10
+
11
+ def dependencies
12
+ [application.builder.infra_setup_checksum]
13
+ end
14
+ end # Source2Dependencies
15
+ end # Stage
16
+ end # Build
17
+ end # Dapp
@@ -4,22 +4,12 @@ module Dapp
4
4
  # Source3
5
5
  class Source3 < SourceBase
6
6
  def initialize(application, next_stage)
7
- @prev_stage = InfraSetup.new(application, self)
7
+ @prev_stage = Source3Dependencies.new(application, self)
8
8
  super
9
9
  end
10
10
 
11
- protected
12
-
13
- def dependencies_checksum
14
- hashsum [super,
15
- setup_dependencies_files_checksum,
16
- *application.builder.setup_checksum]
17
- end
18
-
19
- private
20
-
21
- def setup_dependencies_files_checksum
22
- @setup_files_checksum ||= dependencies_files_checksum(application.config._setup_dependencies)
11
+ def next_source_stage
12
+ super.next_stage
23
13
  end
24
14
  end # Source3
25
15
  end # Stage
@@ -0,0 +1,23 @@
1
+ module Dapp
2
+ module Build
3
+ module Stage
4
+ # Source3Dependencies
5
+ class Source3Dependencies < SourceDependenciesBase
6
+ def initialize(application, next_stage)
7
+ @prev_stage = InfraSetup.new(application, self)
8
+ super
9
+ end
10
+
11
+ def dependencies
12
+ [setup_dependencies_files_checksum, application.builder.setup_checksum]
13
+ end
14
+
15
+ private
16
+
17
+ def setup_dependencies_files_checksum
18
+ @setup_files_checksum ||= dependencies_files_checksum(application.config._setup_dependencies)
19
+ end
20
+ end # Source3Dependencies
21
+ end # Stage
22
+ end # Build
23
+ end # Dapp
@@ -3,32 +3,18 @@ module Dapp
3
3
  module Stage
4
4
  # Source4
5
5
  class Source4 < SourceBase
6
- MAX_PATCH_SIZE = 1024 * 1024
7
-
8
6
  def initialize(application, next_stage)
9
- @prev_stage = ChefCookbooks.new(application, self)
7
+ @prev_stage = Source4Dependencies.new(application, self)
10
8
  super
11
9
  end
12
10
 
13
11
  def prev_source_stage
14
- prev_stage.prev_stage.prev_stage
12
+ super.prev_stage
15
13
  end
16
14
 
17
15
  def next_source_stage
18
16
  next_stage
19
17
  end
20
-
21
- def dependencies_checksum
22
- hashsum [super, (changes_size_since_source3 / MAX_PATCH_SIZE).to_i]
23
- end
24
-
25
- private
26
-
27
- def changes_size_since_source3
28
- application.git_artifacts.map do |git_artifact|
29
- git_artifact.patch_size(prev_source_stage.layer_commit(git_artifact), git_artifact.latest_commit)
30
- end.reduce(0, :+)
31
- end
32
18
  end # Source4
33
19
  end # Stage
34
20
  end # Build
@@ -0,0 +1,27 @@
1
+ module Dapp
2
+ module Build
3
+ module Stage
4
+ # Source4Dependencies
5
+ class Source4Dependencies < SourceDependenciesBase
6
+ MAX_PATCH_SIZE = 1024 * 1024
7
+
8
+ def initialize(application, next_stage)
9
+ @prev_stage = ChefCookbooks.new(application, self)
10
+ super
11
+ end
12
+
13
+ def dependencies
14
+ [(changes_size_since_source3 / MAX_PATCH_SIZE).to_i]
15
+ end
16
+
17
+ private
18
+
19
+ def changes_size_since_source3
20
+ application.git_artifacts.map do |git_artifact|
21
+ git_artifact.patch_size(prev_stage.prev_stage.prev_stage.layer_commit(git_artifact), git_artifact.latest_commit)
22
+ end.reduce(0, :+)
23
+ end
24
+ end # Source4Dependencies
25
+ end # Stage
26
+ end # Build
27
+ end # Dapp
@@ -3,9 +3,9 @@ module Dapp
3
3
  module Stage
4
4
  # Source5
5
5
  class Source5 < SourceBase
6
- def initialize(application)
6
+ def initialize(application, next_stage)
7
7
  @prev_stage = Source4.new(application, self)
8
- @application = application
8
+ super
9
9
  end
10
10
 
11
11
  def prev_source_stage
@@ -16,27 +16,28 @@ module Dapp
16
16
  nil
17
17
  end
18
18
 
19
- def signature
20
- hashsum [super, change_options]
19
+ def dependencies_stage
20
+ nil
21
21
  end
22
22
 
23
- def image
24
- super do |image|
25
- change_options.each do |k, v|
26
- next if v.nil? || v.empty?
27
- image.public_send("add_change_#{k}", v)
28
- end
29
- end
23
+ def dependencies
24
+ [commit_list]
30
25
  end
31
26
 
32
- protected
27
+ def layer_commit(git_artifact)
28
+ commits[git_artifact] ||= begin
29
+ git_artifact.latest_commit
30
+ end
31
+ end
33
32
 
34
- def change_options
35
- application.config._docker._change_options
33
+ def empty?
34
+ dependencies_empty?
36
35
  end
37
36
 
38
- def layers_commits_write!
39
- nil
37
+ private
38
+
39
+ def commit_list
40
+ application.git_artifacts.map { |git_artifact| layer_commit(git_artifact) }
40
41
  end
41
42
  end # Source5
42
43
  end # Stage
@@ -8,48 +8,38 @@ module Dapp
8
8
  GITARTIFACT_IMAGE = 'dappdeps/gitartifact:0.1.3'.freeze
9
9
 
10
10
  def prev_source_stage
11
- prev_stage.prev_stage
11
+ dependencies_stage.prev_stage.prev_stage
12
12
  end
13
13
 
14
14
  def next_source_stage
15
- next_stage.next_stage
15
+ next_stage.next_stage.next_stage
16
16
  end
17
17
 
18
- def save_in_cache!
19
- super
20
- layers_commits_write!
21
- end
22
-
23
- def signature
24
- hashsum [dependencies_checksum, *commit_list]
18
+ def dependencies_stage
19
+ prev_stage
25
20
  end
26
21
 
27
22
  def image
28
23
  super do |image|
29
- bash_commands = []
30
- volumes = []
31
- application.git_artifacts.each do |git_artifact|
32
- volumes << "#{git_artifact.repo.path}:#{git_artifact.repo.container_path}"
33
- bash_commands.concat(git_artifact.send(apply_command_method, self))
34
- end
24
+ image.add_volumes_from gitartifact_container
25
+ image.add_command 'export PATH=/.dapp/deps/gitartifact/bin:$PATH'
35
26
 
36
- unless bash_commands.empty?
37
- image.add_volumes_from(gitartifact_container)
38
- image.add_volume(volumes)
39
- image.add_commands 'export PATH=/.dapp/deps/gitartifact/bin:$PATH', *bash_commands
27
+ application.git_artifacts.each do |git_artifact|
28
+ image.add_volume "#{git_artifact.repo.path}:#{git_artifact.repo.container_path}:ro"
29
+ image.add_command git_artifact.send(apply_command_method, self)
40
30
  end
41
31
  yield image if block_given?
42
32
  end
43
33
  end
44
34
 
45
- def dependencies_checksum
46
- hashsum [prev_stage.signature, artifacts_signatures]
35
+ def empty?
36
+ dependencies_stage.empty?
47
37
  end
48
38
 
49
39
  def layer_commit(git_artifact)
50
40
  commits[git_artifact] ||= begin
51
- if layer_commit_file_path(git_artifact).exist?
52
- layer_commit_file_path(git_artifact).read.strip
41
+ if dependencies_stage && dependencies_stage.image.tagged?
42
+ dependencies_stage.image.labels[git_artifact.full_name]
53
43
  else
54
44
  git_artifact.latest_commit
55
45
  end
@@ -81,24 +71,12 @@ module Dapp
81
71
  true
82
72
  end
83
73
 
84
- def apply_command_method
85
- :apply_patch_command
86
- end
87
-
88
- def commit_list
89
- application.git_artifacts.map { |git_artifact| layer_commit(git_artifact) }
90
- end
91
-
92
- def layers_commits_write!
93
- application.git_artifacts.each { |git_artifact| layer_commit_file_path(git_artifact).write(layer_commit(git_artifact)) }
94
- end
95
-
96
- def layer_commit_file_path(git_artifact)
97
- application.metadata_path git_artifact.filename ".#{name}.#{git_artifact.paramshash}.#{dependencies_checksum}.commit"
74
+ def ignore_log_commands?
75
+ true
98
76
  end
99
77
 
100
- def dependencies_files_checksum(regs)
101
- hashsum(regs.map { |reg| Dir[File.join(application.home_path, reg)].map { |f| File.read(f) if File.file?(f) } })
78
+ def apply_command_method
79
+ :apply_patch_command
102
80
  end
103
81
 
104
82
  private
@@ -0,0 +1,28 @@
1
+ module Dapp
2
+ module Build
3
+ module Stage
4
+ # base of source dependencies stages
5
+ class SourceDependenciesBase < Base
6
+ def image
7
+ super do |image|
8
+ application.git_artifacts.each do |git_artifact|
9
+ image.add_change_label(git_artifact.full_name.to_sym => git_artifact.latest_commit)
10
+ end
11
+ end
12
+ end
13
+
14
+ def empty?
15
+ application.git_artifacts.empty? ? true : false
16
+ end
17
+
18
+ protected
19
+
20
+ def dependencies_files_checksum(regs)
21
+ unless (files = regs.map { |reg| Dir[File.join(application.home_path, reg)].map { |f| File.read(f) if File.file?(f) } }).empty?
22
+ hashsum files
23
+ end
24
+ end
25
+ end # SourceBase
26
+ end # Stage
27
+ end # Build
28
+ end # Dapp