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.
- checksums.yaml +4 -4
- data/config/en/common.yml +1 -0
- data/config/en/net_status.yml +2 -2
- data/lib/dapp.rb +9 -2
- data/lib/dapp/application.rb +2 -5
- data/lib/dapp/application/path.rb +3 -3
- data/lib/dapp/build/stage/artifact.rb +35 -0
- data/lib/dapp/build/stage/base.rb +42 -20
- data/lib/dapp/build/stage/chef_cookbooks.rb +12 -2
- data/lib/dapp/build/stage/docker_instructions.rb +31 -0
- data/lib/dapp/build/stage/from.rb +5 -4
- data/lib/dapp/build/stage/infra_install.rb +6 -2
- data/lib/dapp/build/stage/infra_setup.rb +8 -0
- data/lib/dapp/build/stage/install.rb +8 -0
- data/lib/dapp/build/stage/mod/artifact.rb +16 -21
- data/lib/dapp/build/stage/mod/logging.rb +8 -2
- data/lib/dapp/build/stage/setup.rb +8 -0
- data/lib/dapp/build/stage/source_1.rb +4 -14
- data/lib/dapp/build/stage/source_1_archive.rb +2 -2
- data/lib/dapp/build/stage/source_1_archive_dependencies.rb +13 -0
- data/lib/dapp/build/stage/source_1_dependencies.rb +27 -0
- data/lib/dapp/build/stage/source_2.rb +3 -6
- data/lib/dapp/build/stage/source_2_dependencies.rb +17 -0
- data/lib/dapp/build/stage/source_3.rb +3 -13
- data/lib/dapp/build/stage/source_3_dependencies.rb +23 -0
- data/lib/dapp/build/stage/source_4.rb +2 -16
- data/lib/dapp/build/stage/source_4_dependencies.rb +27 -0
- data/lib/dapp/build/stage/source_5.rb +17 -16
- data/lib/dapp/build/stage/source_base.rb +17 -39
- data/lib/dapp/build/stage/source_dependencies_base.rb +28 -0
- data/lib/dapp/builder/base.rb +16 -0
- data/lib/dapp/builder/chef.rb +49 -29
- data/lib/dapp/builder/shell.rb +13 -4
- data/lib/dapp/cli.rb +1 -2
- data/lib/dapp/cli/build.rb +5 -5
- data/lib/dapp/cli/push.rb +0 -4
- data/lib/dapp/cli/run.rb +0 -3
- data/lib/dapp/config/artifact.rb +0 -23
- data/lib/dapp/controller.rb +9 -9
- data/lib/dapp/error/dappfile.rb +6 -0
- data/lib/dapp/git_artifact.rb +2 -2
- data/lib/dapp/image/argument.rb +2 -4
- data/lib/dapp/image/docker.rb +5 -0
- data/lib/dapp/image/stage.rb +4 -0
- data/lib/dapp/version.rb +2 -2
- metadata +10 -3
- data/lib/dapp/cli/metadata.rb +0 -18
- data/lib/dapp/cli/metadata/flush.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344169cb4810496ce7bdffabb39b0e0d67d922be
|
4
|
+
data.tar.gz: 80300942c9abcfd25956099e7680d06c980deba1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c9f6344686884f6be5132acad1e4be8a433dbdc7362b07a0e9cdede2d45aeebf699536d4860e7b82d69c060ffee7c52c796488181cd0c2fba140817ed3ae592
|
7
|
+
data.tar.gz: d7ec6ba5e7adcaa342c64cb5258e1cb74a6a4579d522e13c863dee0e24a0c9fdb4df04fcc80cbd463ad5a7c6a0c54206017da8e8421775a5d2ba402a1cd952a9
|
data/config/en/common.yml
CHANGED
data/config/en/net_status.yml
CHANGED
@@ -8,6 +8,8 @@ en:
|
|
8
8
|
application_not_run: "Application run failed!"
|
9
9
|
git_branch_without_name: "Application has specific revision that isn't associated with a branch name!"
|
10
10
|
ci_environment_required: 'CI environment required (Travis or GitLab CI)!'
|
11
|
+
dappfile:
|
12
|
+
incorrect: "Dappfile '%{path}' with '%{error}':\n%{message}"
|
11
13
|
build:
|
12
14
|
from_image_required: 'Missing from_image!'
|
13
15
|
image_already_untagged: "Image `%{name}` already untagged!"
|
@@ -24,8 +26,6 @@ en:
|
|
24
26
|
builder_type_unsupported: "Defined unsupported builder type `%{type}`!"
|
25
27
|
docker_from_not_defined: "Docker `from` not defined!"
|
26
28
|
artifact_unexpected_attribute: "Artifact doesn't has attribute '%{attr}'!"
|
27
|
-
stage_artifact_not_associated: "Artifact not associated with any stage!"
|
28
|
-
stage_artifact_incorrect_associated_value: "Artifact option '%{option}' has incorrect value '%{value}'!"
|
29
29
|
git_artifact_unexpected_attribute: "'%{type}' git artifact doesn't has attribute '%{attr}'!"
|
30
30
|
chef:
|
31
31
|
stage_path_overlap: "Cannot install '%{cookbook}' cookbook's path %{from} into %{to}: already exists"
|
data/lib/dapp.rb
CHANGED
@@ -27,6 +27,7 @@ require 'dapp/helper/shellout'
|
|
27
27
|
require 'dapp/helper/net_status'
|
28
28
|
require 'dapp/error/base'
|
29
29
|
require 'dapp/error/application'
|
30
|
+
require 'dapp/error/dappfile'
|
30
31
|
require 'dapp/error/build'
|
31
32
|
require 'dapp/error/config'
|
32
33
|
require 'dapp/error/controller'
|
@@ -37,8 +38,6 @@ require 'dapp/cli/build'
|
|
37
38
|
require 'dapp/cli/push'
|
38
39
|
require 'dapp/cli/smartpush'
|
39
40
|
require 'dapp/cli/list'
|
40
|
-
require 'dapp/cli/metadata'
|
41
|
-
require 'dapp/cli/metadata/flush'
|
42
41
|
require 'dapp/cli/stages'
|
43
42
|
require 'dapp/cli/stages/flush'
|
44
43
|
require 'dapp/cli/stages/cleanup'
|
@@ -61,18 +60,26 @@ require 'dapp/build/stage/mod/artifact'
|
|
61
60
|
require 'dapp/build/stage/mod/logging'
|
62
61
|
require 'dapp/build/stage/base'
|
63
62
|
require 'dapp/build/stage/source_base'
|
63
|
+
require 'dapp/build/stage/source_dependencies_base'
|
64
64
|
require 'dapp/build/stage/from'
|
65
65
|
require 'dapp/build/stage/infra_install'
|
66
66
|
require 'dapp/build/stage/infra_setup'
|
67
67
|
require 'dapp/build/stage/install'
|
68
|
+
require 'dapp/build/stage/artifact'
|
68
69
|
require 'dapp/build/stage/setup'
|
69
70
|
require 'dapp/build/stage/chef_cookbooks'
|
70
71
|
require 'dapp/build/stage/source_1_archive'
|
72
|
+
require 'dapp/build/stage/source_1_archive_dependencies'
|
71
73
|
require 'dapp/build/stage/source_1'
|
74
|
+
require 'dapp/build/stage/source_1_dependencies'
|
72
75
|
require 'dapp/build/stage/source_2'
|
76
|
+
require 'dapp/build/stage/source_2_dependencies'
|
73
77
|
require 'dapp/build/stage/source_3'
|
78
|
+
require 'dapp/build/stage/source_3_dependencies'
|
74
79
|
require 'dapp/build/stage/source_4'
|
80
|
+
require 'dapp/build/stage/source_4_dependencies'
|
75
81
|
require 'dapp/build/stage/source_5'
|
82
|
+
require 'dapp/build/stage/docker_instructions'
|
76
83
|
require 'dapp/controller'
|
77
84
|
require 'dapp/application/git_artifact'
|
78
85
|
require 'dapp/application/logging'
|
data/lib/dapp/application.rb
CHANGED
@@ -16,17 +16,14 @@ module Dapp
|
|
16
16
|
attr_reader :ignore_git_fetch
|
17
17
|
attr_reader :is_artifact
|
18
18
|
|
19
|
-
STAGES = [:from, :infra_install, :source_1_archive, :source_1, :install, :source_2,
|
20
|
-
:infra_setup, :source_3, :chef_cookbooks, :setup, :source_4, :source_5].freeze
|
21
|
-
|
22
19
|
def initialize(config:, cli_options:, ignore_git_fetch: false, is_artifact: false)
|
23
20
|
@config = config
|
24
21
|
@cli_options = cli_options
|
25
22
|
|
26
23
|
@tmp_path = Dir.mktmpdir(cli_options[:tmp_dir_prefix] || 'dapp-')
|
27
|
-
@
|
24
|
+
@build_path = cli_options[:build_dir] || home_path('.dapps-build')
|
28
25
|
|
29
|
-
@last_stage = Build::Stage::
|
26
|
+
@last_stage = Build::Stage::DockerInstructions.new(self)
|
30
27
|
@ignore_git_fetch = ignore_git_fetch
|
31
28
|
@is_artifact = is_artifact
|
32
29
|
end
|
@@ -8,11 +8,11 @@ module Dapp
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def tmp_path(*path)
|
11
|
-
make_path(@tmp_path, *path).expand_path.tap { |p|
|
11
|
+
make_path(@tmp_path, *path).expand_path.tap { |p| p.parent.mkpath }
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
make_path(@
|
14
|
+
def build_path(*path)
|
15
|
+
make_path(@build_path, home_path.basename, *path).expand_path.tap { |p| p.parent.mkpath }
|
16
16
|
end
|
17
17
|
|
18
18
|
def container_dapp_path(*path)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Dapp
|
2
|
+
module Build
|
3
|
+
module Stage
|
4
|
+
# Artifact
|
5
|
+
class Artifact < Base
|
6
|
+
include Mod::Artifact
|
7
|
+
|
8
|
+
def initialize(application, next_stage)
|
9
|
+
@prev_stage = Install.new(application, self)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def dependencies
|
14
|
+
artifacts_signatures
|
15
|
+
end
|
16
|
+
|
17
|
+
def image
|
18
|
+
super do |image|
|
19
|
+
artifacts.each { |artifact| apply_artifact(artifact, image) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def should_be_not_detailed?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def ignore_log_commands?
|
30
|
+
true
|
31
|
+
end
|
32
|
+
end # Artifact
|
33
|
+
end # Stage
|
34
|
+
end # Build
|
35
|
+
end # Dapp
|
@@ -5,7 +5,6 @@ module Dapp
|
|
5
5
|
class Base
|
6
6
|
include Helper::Sha256
|
7
7
|
include Helper::Trivia
|
8
|
-
include Mod::Artifact
|
9
8
|
include Mod::Logging
|
10
9
|
|
11
10
|
attr_accessor :prev_stage, :next_stage
|
@@ -21,41 +20,56 @@ module Dapp
|
|
21
20
|
def build!
|
22
21
|
return if should_be_skipped?
|
23
22
|
prev_stage.build! if prev_stage
|
24
|
-
image_build
|
23
|
+
image_build unless empty? && !application.log_verbose?
|
25
24
|
raise Exception::IntrospectImage, data: { built_id: image.built_id, options: image.send(:prepared_options) } if should_be_introspected?
|
26
25
|
end
|
27
26
|
|
28
27
|
def save_in_cache!
|
29
|
-
|
30
|
-
|
28
|
+
prev_stage.save_in_cache! if prev_stage
|
29
|
+
return unless should_be_tagged?
|
31
30
|
image.tag!(log_verbose: application.log_verbose?, log_time: application.log_time?) unless application.dry_run?
|
32
31
|
end
|
33
32
|
|
34
|
-
def signature
|
35
|
-
hashsum [prev_stage.signature, artifacts_signatures]
|
36
|
-
end
|
37
|
-
|
38
33
|
def image
|
39
34
|
@image ||= begin
|
40
|
-
|
41
|
-
image
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
35
|
+
if empty?
|
36
|
+
prev_stage.image
|
37
|
+
else
|
38
|
+
Image::Stage.new(name: image_name, from: from_image).tap do |image|
|
39
|
+
image.add_change_label dapp: application.config._basename
|
40
|
+
yield image if block_given?
|
41
|
+
end
|
46
42
|
end
|
47
43
|
end
|
48
44
|
end
|
49
45
|
|
50
|
-
|
46
|
+
def empty?
|
47
|
+
dependencies_empty?
|
48
|
+
end
|
51
49
|
|
52
|
-
def
|
53
|
-
|
50
|
+
def dependencies_empty?
|
51
|
+
dependencies.flatten.compact.delete_if { |val| val.respond_to?(:empty?) && val.empty? }.empty?
|
52
|
+
end
|
53
|
+
|
54
|
+
def signature
|
55
|
+
if empty?
|
56
|
+
prev_stage.signature
|
57
|
+
else
|
58
|
+
hashsum [prev_stage.signature, *dependencies.flatten]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def dependencies
|
63
|
+
[]
|
54
64
|
end
|
55
65
|
|
66
|
+
protected
|
67
|
+
|
56
68
|
# rubocop:disable Metrics/AbcSize
|
57
69
|
def image_build
|
58
|
-
if
|
70
|
+
if empty?
|
71
|
+
application.log_state(name, state: application.t(code: 'state.empty'))
|
72
|
+
elsif image.tagged?
|
59
73
|
application.log_state(name, state: application.t(code: 'state.using_cache'))
|
60
74
|
elsif should_be_not_present?
|
61
75
|
application.log_state(name, state: application.t(code: 'state.not_present'))
|
@@ -78,14 +92,22 @@ module Dapp
|
|
78
92
|
introspect_before_error: application.cli_options[:introspect_before_error])
|
79
93
|
end
|
80
94
|
|
95
|
+
def should_be_tagged?
|
96
|
+
!(image.tagged? || empty?)
|
97
|
+
end
|
98
|
+
|
99
|
+
def image_name
|
100
|
+
"#{application.config._basename}-dappstage:#{signature}"
|
101
|
+
end
|
102
|
+
|
81
103
|
def from_image
|
82
104
|
prev_stage.image if prev_stage || begin
|
83
105
|
raise Error::Build, code: :from_image_required
|
84
106
|
end
|
85
107
|
end
|
86
108
|
|
87
|
-
def
|
88
|
-
|
109
|
+
def name
|
110
|
+
class_to_lowercase.to_sym
|
89
111
|
end
|
90
112
|
end # Base
|
91
113
|
end # Stage
|
@@ -8,8 +8,8 @@ module Dapp
|
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def dependencies
|
12
|
+
[application.builder.chef_cookbooks_checksum]
|
13
13
|
end
|
14
14
|
|
15
15
|
def image
|
@@ -17,6 +17,16 @@ module Dapp
|
|
17
17
|
application.builder.chef_cookbooks(image)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def should_be_not_detailed?
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
def ignore_log_commands?
|
28
|
+
true
|
29
|
+
end
|
20
30
|
end # ChefCookbooks
|
21
31
|
end # Stage
|
22
32
|
end # Build
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Dapp
|
2
|
+
module Build
|
3
|
+
module Stage
|
4
|
+
# DockerInstructions
|
5
|
+
class DockerInstructions < Base
|
6
|
+
def initialize(application)
|
7
|
+
@prev_stage = Source5.new(application, self)
|
8
|
+
@application = application
|
9
|
+
end
|
10
|
+
|
11
|
+
def dependencies
|
12
|
+
[change_options]
|
13
|
+
end
|
14
|
+
|
15
|
+
def image
|
16
|
+
super do |image|
|
17
|
+
change_options.each do |k, v|
|
18
|
+
image.public_send("add_change_#{k}", v)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def change_options
|
26
|
+
@change_options ||= application.config._docker._change_options.delete_if { |_, val| val.nil? || (val.respond_to?(:empty?) && val.empty?) }
|
27
|
+
end
|
28
|
+
end # DockerInstructions
|
29
|
+
end # Stage
|
30
|
+
end # Build
|
31
|
+
end # Dapp
|
@@ -4,10 +4,11 @@ module Dapp
|
|
4
4
|
# From
|
5
5
|
class From < Base
|
6
6
|
def signature
|
7
|
-
hashsum [
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
hashsum [*dependencies.flatten]
|
8
|
+
end
|
9
|
+
|
10
|
+
def dependencies
|
11
|
+
[from_image_name, application.config._docker._from_cache_version, Dapp::BUILD_CACHE_VERSION]
|
11
12
|
end
|
12
13
|
|
13
14
|
def save_in_cache!
|
@@ -8,8 +8,12 @@ module Dapp
|
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def empty?
|
12
|
+
super && !application.builder.infra_install?
|
13
|
+
end
|
14
|
+
|
15
|
+
def dependencies
|
16
|
+
[application.builder.infra_install_checksum]
|
13
17
|
end
|
14
18
|
|
15
19
|
def image
|
@@ -5,25 +5,19 @@ module Dapp
|
|
5
5
|
module Mod
|
6
6
|
# Artifact
|
7
7
|
module Artifact
|
8
|
-
def
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
application.with_log_indent do
|
22
|
-
{
|
23
|
-
name: artifact._config._name,
|
24
|
-
options: artifact._artifact_options,
|
25
|
-
app: Application.new(artifact_app_options(artifact, verbose)).tap(&:build!)
|
26
|
-
}
|
8
|
+
def artifacts
|
9
|
+
@artifacts ||= begin
|
10
|
+
verbose = application.log_verbose?
|
11
|
+
application.config._artifact.map do |artifact|
|
12
|
+
process = application.t(code: 'process.artifact_building', data: { name: artifact._config._name })
|
13
|
+
application.log_secondary_process(process, short: !verbose) do
|
14
|
+
application.with_log_indent do
|
15
|
+
{
|
16
|
+
name: artifact._config._name,
|
17
|
+
options: artifact._artifact_options,
|
18
|
+
app: Application.new(artifact_app_options(artifact, verbose)).tap(&:build!)
|
19
|
+
}
|
20
|
+
end
|
27
21
|
end
|
28
22
|
end
|
29
23
|
end
|
@@ -39,7 +33,7 @@ module Dapp
|
|
39
33
|
end
|
40
34
|
|
41
35
|
def artifacts_signatures
|
42
|
-
|
36
|
+
artifacts.map { |artifact| hashsum [artifact[:app].signature, artifact[:options]] }
|
43
37
|
end
|
44
38
|
|
45
39
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
@@ -63,7 +57,8 @@ module Dapp
|
|
63
57
|
end
|
64
58
|
|
65
59
|
commands = safe_cp(application.container_tmp_path('artifact', artifact_name), where_to_add, owner, group, cwd, paths)
|
66
|
-
image.
|
60
|
+
image.add_command commands
|
61
|
+
image.add_volume "#{application.tmp_path('artifact', artifact_name)}:#{application.container_tmp_path('artifact', artifact_name)}:ro"
|
67
62
|
end
|
68
63
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
69
64
|
|