dapp 0.6.1 → 0.6.2
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/bin/dapp +3 -3
- data/config/en/common.yml +19 -4
- data/config/en/net_status.yml +13 -4
- data/lib/dapp.rb +48 -16
- data/lib/dapp/application.rb +75 -40
- data/lib/dapp/application/path.rb +3 -2
- data/lib/dapp/application/stages.rb +59 -0
- data/lib/dapp/artifact.rb +22 -0
- data/lib/dapp/build/stage/after_install_artifact.rb +13 -0
- data/lib/dapp/build/stage/after_setup_artifact.rb +17 -0
- data/lib/dapp/build/stage/artifact_base.rb +80 -0
- data/lib/dapp/build/stage/artifact_default.rb +62 -0
- data/lib/dapp/build/stage/base.rb +47 -12
- data/lib/dapp/build/stage/before_install.rb +6 -5
- data/lib/dapp/build/stage/before_install_artifact.rb +13 -0
- data/lib/dapp/build/stage/before_setup.rb +7 -8
- data/lib/dapp/build/stage/before_setup_artifact.rb +13 -0
- data/lib/dapp/build/stage/build_artifact.rb +32 -0
- data/lib/dapp/build/stage/docker_instructions.rb +4 -22
- data/lib/dapp/build/stage/from.rb +7 -8
- data/lib/dapp/build/stage/ga_archive.rb +1 -1
- data/lib/dapp/build/stage/ga_archive_dependencies.rb +1 -1
- data/lib/dapp/build/stage/ga_artifact_patch.rb +21 -0
- data/lib/dapp/build/stage/ga_base.rb +6 -29
- data/lib/dapp/build/stage/ga_dependencies_base.rb +4 -13
- data/lib/dapp/build/stage/ga_latest_patch.rb +2 -2
- data/lib/dapp/build/stage/import_artifact.rb +69 -0
- data/lib/dapp/build/stage/install/ga_post_install_patch.rb +1 -1
- data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +1 -1
- data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +1 -7
- data/lib/dapp/build/stage/install/install.rb +12 -7
- data/lib/dapp/build/stage/mod/logging.rb +10 -7
- data/lib/dapp/build/stage/setup/chef_cookbooks.rb +3 -4
- data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +1 -1
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +2 -2
- data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +2 -8
- data/lib/dapp/build/stage/setup/setup.rb +12 -7
- data/lib/dapp/builder/base.rb +13 -1
- data/lib/dapp/builder/chef.rb +125 -79
- data/lib/dapp/builder/chef/cookbook_metadata.rb +1 -1
- data/lib/dapp/builder/shell.rb +2 -3
- data/lib/dapp/cli.rb +3 -3
- data/lib/dapp/cli/base.rb +0 -2
- data/lib/dapp/cli/bp.rb +0 -4
- data/lib/dapp/cli/build.rb +3 -7
- data/lib/dapp/cli/cleanup.rb +0 -2
- data/lib/dapp/cli/list.rb +0 -2
- data/lib/dapp/cli/mrproper.rb +22 -0
- data/lib/dapp/cli/push.rb +4 -3
- data/lib/dapp/cli/run.rb +0 -2
- data/lib/dapp/cli/spush.rb +0 -2
- data/lib/dapp/cli/stage_image.rb +24 -0
- data/lib/dapp/cli/stages.rb +7 -5
- data/lib/dapp/cli/stages/cleanup_local.rb +28 -0
- data/lib/dapp/cli/stages/cleanup_repo.rb +24 -0
- data/lib/dapp/cli/stages/{flush.rb → flush_local.rb} +4 -6
- data/lib/dapp/cli/stages/{cleanup.rb → flush_repo.rb} +4 -6
- data/lib/dapp/cli/stages/pull.rb +28 -0
- data/lib/dapp/cli/stages/push.rb +24 -0
- data/lib/dapp/config/application.rb +185 -44
- data/lib/dapp/config/artifact.rb +10 -50
- data/lib/dapp/config/directive/artifact.rb +77 -0
- data/lib/dapp/config/directive/build_dir.rb +9 -0
- data/lib/dapp/config/directive/chef.rb +95 -0
- data/lib/dapp/config/directive/docker/artifact.rb +26 -0
- data/lib/dapp/config/directive/docker/base.rb +91 -0
- data/lib/dapp/config/directive/git_artifact.rb +59 -0
- data/lib/dapp/config/directive/shell/artifact.rb +38 -0
- data/lib/dapp/config/directive/shell/base.rb +85 -0
- data/lib/dapp/config/directive/tmp_dir.rb +36 -0
- data/lib/dapp/config/main.rb +1 -7
- data/lib/dapp/core_ext/hash.rb +21 -0
- data/lib/dapp/docker_registry/base.rb +60 -5
- data/lib/dapp/docker_registry/mod/request.rb +2 -14
- data/lib/dapp/git_artifact.rb +32 -23
- data/lib/dapp/git_repo/base.rb +1 -1
- data/lib/dapp/image/argument.rb +3 -3
- data/lib/dapp/image/docker.rb +13 -16
- data/lib/dapp/image/scratch.rb +29 -0
- data/lib/dapp/image/stage.rb +33 -23
- data/lib/dapp/lock/base.rb +18 -11
- data/lib/dapp/lock/file.rb +18 -16
- data/lib/dapp/prctl.rb +1 -0
- data/lib/dapp/project.rb +22 -9
- data/lib/dapp/project/command/bp.rb +2 -5
- data/lib/dapp/project/command/build.rb +1 -2
- data/lib/dapp/project/command/cleanup.rb +9 -7
- data/lib/dapp/project/command/common.rb +37 -12
- data/lib/dapp/project/command/mrproper.rb +57 -0
- data/lib/dapp/project/command/push.rb +8 -2
- data/lib/dapp/project/command/run.rb +1 -1
- data/lib/dapp/project/command/stage_image.rb +15 -0
- data/lib/dapp/project/command/stages/cleanup_local.rb +100 -0
- data/lib/dapp/project/command/stages/cleanup_repo.rb +65 -0
- data/lib/dapp/project/command/stages/common.rb +48 -0
- data/lib/dapp/project/command/stages/flush_local.rb +24 -0
- data/lib/dapp/project/command/stages/flush_repo.rb +22 -0
- data/lib/dapp/project/command/stages/pull.rb +26 -0
- data/lib/dapp/project/command/stages/push.rb +22 -0
- data/lib/dapp/project/dappfile.rb +3 -1
- data/lib/dapp/project/deps/base.rb +52 -0
- data/lib/dapp/project/deps/gitartifact.rb +36 -0
- data/lib/dapp/project/lock.rb +20 -13
- data/lib/dapp/project/logging/base.rb +20 -3
- data/lib/dapp/project/logging/i18n.rb +25 -0
- data/lib/dapp/project/logging/paint.rb +47 -0
- data/lib/dapp/project/logging/process.rb +17 -10
- data/lib/dapp/project/shellout/base.rb +74 -0
- data/lib/dapp/project/shellout/streaming.rb +49 -0
- data/lib/dapp/project/shellout/system.rb +72 -0
- data/lib/dapp/project/ssh_agent.rb +8 -9
- data/lib/dapp/version.rb +1 -1
- metadata +48 -17
- data/lib/dapp/build/stage/artifact.rb +0 -40
- data/lib/dapp/build/stage/mod/artifact.rb +0 -79
- data/lib/dapp/config/chef.rb +0 -51
- data/lib/dapp/config/docker.rb +0 -82
- data/lib/dapp/config/git_artifact.rb +0 -51
- data/lib/dapp/config/shell.rb +0 -64
- data/lib/dapp/helper/i18n.rb +0 -20
- data/lib/dapp/helper/paint.rb +0 -27
- data/lib/dapp/helper/shellout.rb +0 -63
- data/lib/dapp/helper/streaming.rb +0 -47
- data/lib/dapp/project/command/stages_cleanup.rb +0 -72
- data/lib/dapp/project/command/stages_flush.rb +0 -20
- data/lib/dapp/project/paint.rb +0 -16
@@ -0,0 +1,85 @@
|
|
1
|
+
module Dapp
|
2
|
+
module Config
|
3
|
+
module Directive
|
4
|
+
module Shell
|
5
|
+
# Base
|
6
|
+
class Base
|
7
|
+
attr_reader :_before_install, :_before_setup, :_install, :_setup
|
8
|
+
attr_reader :_before_install_cache_version, :_before_setup_cache_version, :_install_cache_version, :_setup_cache_version
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@_before_install = []
|
12
|
+
@_before_setup = []
|
13
|
+
@_install = []
|
14
|
+
@_setup = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def before_install(*args, cache_version: nil)
|
18
|
+
@_before_install.concat(args)
|
19
|
+
@_before_install_cache_version = cache_version
|
20
|
+
end
|
21
|
+
|
22
|
+
def before_setup(*args, cache_version: nil)
|
23
|
+
@_before_setup.concat(args)
|
24
|
+
@_before_setup_cache_version = cache_version
|
25
|
+
end
|
26
|
+
|
27
|
+
def install(*args, cache_version: nil)
|
28
|
+
@_install.concat(args)
|
29
|
+
@_install_cache_version = cache_version
|
30
|
+
end
|
31
|
+
|
32
|
+
def setup(*args, cache_version: nil)
|
33
|
+
@_setup.concat(args)
|
34
|
+
@_setup_cache_version = cache_version
|
35
|
+
end
|
36
|
+
|
37
|
+
def reset_before_install
|
38
|
+
@_before_install = []
|
39
|
+
end
|
40
|
+
|
41
|
+
def reset_before_setup
|
42
|
+
@_before_setup = []
|
43
|
+
end
|
44
|
+
|
45
|
+
def reset_install
|
46
|
+
@_install = []
|
47
|
+
end
|
48
|
+
|
49
|
+
def reset_setup
|
50
|
+
@_setup = []
|
51
|
+
end
|
52
|
+
|
53
|
+
def reset_all
|
54
|
+
methods.tap { |arr| arr.delete(__method__) }.grep(/^reset_/).each(&method(:send))
|
55
|
+
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def clone
|
60
|
+
marshal_dup(self)
|
61
|
+
end
|
62
|
+
|
63
|
+
def clone_to_artifact
|
64
|
+
Artifact.new.tap do |shell|
|
65
|
+
instance_variables.each do |variable|
|
66
|
+
shell.instance_variable_set(variable, marshal_dup(instance_variable_get(variable)))
|
67
|
+
shell.instance_variable_set("#{variable}_cache_version", marshal_dup(instance_variable_get("#{variable}_cache_version")))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def empty?
|
73
|
+
@_before_install.empty? && @_before_setup.empty? && @_install.empty? && @_setup.empty?
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def marshal_dup(obj)
|
79
|
+
Marshal.load(Marshal.dump(obj))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Dapp
|
2
|
+
module Config
|
3
|
+
module Directive
|
4
|
+
# TmpDir
|
5
|
+
class TmpDir
|
6
|
+
attr_reader :_store
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@_store = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def store(*args)
|
13
|
+
_store.concat(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def unstore(*args)
|
17
|
+
@_store -= args
|
18
|
+
end
|
19
|
+
|
20
|
+
def reset
|
21
|
+
@_store = []
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def empty?
|
27
|
+
_store.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
def clone
|
31
|
+
Marshal.load(Marshal.dump(self))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/dapp/config/main.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Dapp
|
2
2
|
module Config
|
3
|
-
#
|
3
|
+
# Application
|
4
4
|
class Main < Application
|
5
5
|
def initialize(dappfile_path:, project:)
|
6
6
|
@project = project
|
@@ -8,12 +8,6 @@ module Dapp
|
|
8
8
|
@_home_path = Pathname.new(dappfile_path).parent.expand_path.to_s
|
9
9
|
@_basename = Pathname.new(@_home_path).basename.to_s
|
10
10
|
@_builder = Pathname.new(@_home_path).join('Berksfile').exist? ? :chef : :shell
|
11
|
-
|
12
|
-
@_docker = Docker.new
|
13
|
-
@_git_artifact = GitArtifact.new
|
14
|
-
@_shell = Shell.new
|
15
|
-
@_chef = Chef.new
|
16
|
-
|
17
11
|
super(nil)
|
18
12
|
end
|
19
13
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Dapp
|
2
|
+
# CoreExt
|
3
|
+
module CoreExt
|
4
|
+
# Hash
|
5
|
+
module Hash
|
6
|
+
def in_depth_merge(hash) # do not conflict with activesupport`s deep_merge
|
7
|
+
merge(hash) do |_, v1, v2|
|
8
|
+
if v1.is_a?(::Hash) && v2.is_a?(::Hash)
|
9
|
+
v1.merge(v2)
|
10
|
+
elsif v1.is_a?(::Array) || v2.is_a?(::Array)
|
11
|
+
[v1, v2].flatten
|
12
|
+
else
|
13
|
+
v2
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
::Hash.send(:include, ::Dapp::CoreExt::Hash)
|
@@ -23,25 +23,80 @@ module Dapp
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def tags
|
26
|
-
@tags ||= api_request(repo_suffix, 'tags/list')['tags']
|
26
|
+
@tags ||= api_request(repo_suffix, 'tags/list')['tags'] || []
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
response =
|
29
|
+
def image_id(tag)
|
30
|
+
response = manifest_v2(tag)
|
31
31
|
response['config']['digest'] if response['schemaVersion'] == 2
|
32
32
|
end
|
33
33
|
|
34
|
+
def image_parent_id(tag)
|
35
|
+
image_history(tag)['container_config']['Image']
|
36
|
+
end
|
37
|
+
|
38
|
+
def image_labels(tag)
|
39
|
+
image_history(tag)['config']['Labels']
|
40
|
+
end
|
41
|
+
|
42
|
+
def image_delete(tag)
|
43
|
+
image_blobs(tag).each { |hash| blob_delete(hash.values.first) }
|
44
|
+
api_request(repo_suffix, "/manifests/#{image_digest(tag)}",
|
45
|
+
method: :delete,
|
46
|
+
expects: [202, 404],
|
47
|
+
headers: { Accept: 'Accept: application/vnd.docker.distribution.manifest.v2+json' })
|
48
|
+
end
|
49
|
+
|
34
50
|
protected
|
35
51
|
|
52
|
+
def image_digest(tag)
|
53
|
+
raw_api_request(repo_suffix, "/manifests/#{tag}",
|
54
|
+
headers: { Accept: 'application/vnd.docker.distribution.manifest.v2+json' }).headers['Docker-Content-Digest']
|
55
|
+
end
|
56
|
+
|
57
|
+
def image_blobs(tag)
|
58
|
+
manifest_v1(tag)['fsLayers']
|
59
|
+
end
|
60
|
+
|
61
|
+
def manifest_v1(tag)
|
62
|
+
api_request(repo_suffix, "/manifests/#{tag}")
|
63
|
+
end
|
64
|
+
|
65
|
+
def manifest_v2(tag)
|
66
|
+
api_request(repo_suffix, "/manifests/#{tag}",
|
67
|
+
headers: { Accept: 'application/vnd.docker.distribution.manifest.v2+json' })
|
68
|
+
end
|
69
|
+
|
70
|
+
def image_history(tag)
|
71
|
+
response = manifest_v1(tag)
|
72
|
+
JSON.load(response['history'].first['v1Compatibility'])
|
73
|
+
end
|
74
|
+
|
75
|
+
def blob_delete(id)
|
76
|
+
api_request(repo_suffix, "/blobs/#{id}",
|
77
|
+
method: :delete, expects: [202, 404])
|
78
|
+
end
|
79
|
+
|
36
80
|
def api_request(*uri, **options)
|
37
|
-
JSON.load(
|
81
|
+
JSON.load(raw_api_request(*uri, **options).body)
|
82
|
+
end
|
83
|
+
|
84
|
+
def raw_api_request(*uri, **options)
|
85
|
+
url = api_url(*uri)
|
86
|
+
request(url, **default_api_options.merge(options))
|
38
87
|
rescue Excon::Error::NotFound
|
39
|
-
raise Error::Registry, code: :
|
88
|
+
raise Error::Registry, code: :page_not_found, data: { url: url }
|
89
|
+
rescue Excon::Error::Unauthorized
|
90
|
+
raise Error::Registry, code: :user_not_authorized
|
40
91
|
end
|
41
92
|
|
42
93
|
def api_url(*uri)
|
43
94
|
File.join(hostname_url, API_VERSION, '/', *uri)
|
44
95
|
end
|
96
|
+
|
97
|
+
def default_api_options
|
98
|
+
{ expects: [200] }
|
99
|
+
end
|
45
100
|
end
|
46
101
|
end # DockerRegistry
|
47
102
|
end # Dapp
|
@@ -5,11 +5,11 @@ module Dapp
|
|
5
5
|
# Request
|
6
6
|
module Request
|
7
7
|
def request(url, **options)
|
8
|
-
raw_request(url,
|
8
|
+
raw_request(url, options.in_depth_merge(authorization_options(url)))
|
9
9
|
end
|
10
10
|
|
11
11
|
def raw_request(url, **options)
|
12
|
-
Excon.new(url).request(
|
12
|
+
Excon.new(url).request(default_request_options.in_depth_merge(options))
|
13
13
|
end
|
14
14
|
|
15
15
|
def url_available?(url)
|
@@ -24,18 +24,6 @@ module Dapp
|
|
24
24
|
def default_request_options
|
25
25
|
{ method: :get, omit_default_port: true }
|
26
26
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def deep_merge(hash1, hash2)
|
31
|
-
hash1.merge(hash2) do |_, v1, v2|
|
32
|
-
if v1.is_a?(Hash) && v2.is_a?(Hash)
|
33
|
-
v1.merge(v2)
|
34
|
-
else
|
35
|
-
[v1, v2].flatten
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
27
|
end
|
40
28
|
end # Mod
|
41
29
|
end # DockerRegistry
|
data/lib/dapp/git_artifact.rb
CHANGED
@@ -6,7 +6,7 @@ module Dapp
|
|
6
6
|
|
7
7
|
# rubocop:disable Metrics/ParameterLists
|
8
8
|
def initialize(repo, where_to_add:, name: nil, branch: nil, commit: nil,
|
9
|
-
cwd: nil, paths: nil, owner: nil, group: nil)
|
9
|
+
cwd: nil, paths: nil, exclude_paths: nil, owner: nil, group: nil)
|
10
10
|
@repo = repo
|
11
11
|
@name = name
|
12
12
|
|
@@ -15,19 +15,21 @@ module Dapp
|
|
15
15
|
@branch = branch || repo.application.project.cli_options[:git_artifact_branch] || repo.branch
|
16
16
|
@commit = commit
|
17
17
|
|
18
|
+
cwd = File.expand_path(File.join('/', cwd))[1..-1] unless cwd.nil? || cwd.empty?
|
18
19
|
@cwd = cwd
|
19
20
|
@paths = paths
|
21
|
+
@exclude_paths = exclude_paths
|
20
22
|
@owner = owner
|
21
23
|
@group = group
|
22
24
|
end
|
23
25
|
# rubocop:enable Metrics/ParameterLists
|
24
26
|
|
25
|
-
def
|
27
|
+
def apply_archive_command(stage)
|
26
28
|
credentials = [:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
|
27
29
|
|
28
|
-
["
|
29
|
-
["
|
30
|
-
"#{sudo}
|
30
|
+
["#{repo.application.project.install_path} #{credentials.join(' ')} -d #{where_to_add}",
|
31
|
+
["#{repo.application.project.git_path} --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{paths.join(' ')}",
|
32
|
+
"#{sudo}#{repo.application.project.tar_path} -x -C #{where_to_add} #{archive_command_excludes.join(' ')}"].join(' | ')]
|
31
33
|
end
|
32
34
|
|
33
35
|
def apply_patch_command(stage)
|
@@ -35,13 +37,24 @@ module Dapp
|
|
35
37
|
prev_commit = stage.prev_g_a_stage.layer_commit(self)
|
36
38
|
|
37
39
|
if prev_commit != current_commit || any_changes?(prev_commit, current_commit)
|
38
|
-
[["
|
39
|
-
"#{sudo}
|
40
|
+
[["#{repo.application.project.git_path} --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
|
41
|
+
"#{sudo}#{repo.application.project.git_path} apply --whitespace=nowarn --directory=#{where_to_add} #{patch_command_excludes.join(' ')} --unsafe-paths"].join(' | ')]
|
40
42
|
else
|
41
43
|
[]
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
47
|
+
def archive_command_excludes
|
48
|
+
exclude_paths.map { |path| %(--exclude=#{path}) }
|
49
|
+
end
|
50
|
+
|
51
|
+
def patch_command_excludes
|
52
|
+
exclude_paths.map do |path|
|
53
|
+
base = File.join(where_to_add, path)
|
54
|
+
path =~ /[\*\?\[\]\{\}]/ ? %(--exclude=#{base} ) : %(--exclude=#{base} --exclude=#{File.join(base, '*')})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
45
58
|
def any_changes?(from, to = latest_commit)
|
46
59
|
!repo.git_bare(diff_command(from, to, quiet: true), returns: [0, 1]).status.success?
|
47
60
|
end
|
@@ -55,11 +68,19 @@ module Dapp
|
|
55
68
|
end
|
56
69
|
|
57
70
|
def paramshash
|
58
|
-
Digest::SHA256.hexdigest [where_to_add, cwd, paths, owner, group].map(&:to_s).join(':::')
|
71
|
+
Digest::SHA256.hexdigest [where_to_add, cwd, *paths, *exclude_paths, owner, group].map(&:to_s).join(':::')
|
72
|
+
end
|
73
|
+
|
74
|
+
def exclude_paths(with_cwd = false)
|
75
|
+
base_paths(@exclude_paths, with_cwd)
|
59
76
|
end
|
60
77
|
|
61
78
|
def paths(with_cwd = false)
|
62
|
-
|
79
|
+
base_paths(@paths, with_cwd)
|
80
|
+
end
|
81
|
+
|
82
|
+
def base_paths(paths, with_cwd = false)
|
83
|
+
[paths].flatten.compact.map { |path| (with_cwd && cwd ? File.join(cwd, path) : path).gsub(%r{^\/*|\/*$}, '') }
|
63
84
|
end
|
64
85
|
|
65
86
|
def full_name
|
@@ -75,24 +96,12 @@ module Dapp
|
|
75
96
|
attr_reader :owner
|
76
97
|
attr_reader :group
|
77
98
|
|
78
|
-
def sudo_format_user(user)
|
79
|
-
user.to_s.to_i.to_s == user ? "\\\##{user}" : user
|
80
|
-
end
|
81
|
-
|
82
99
|
def sudo
|
83
|
-
|
84
|
-
|
85
|
-
if owner || group
|
86
|
-
sudo = 'sudo -E '
|
87
|
-
sudo += "-u #{sudo_format_user(owner)} " if owner
|
88
|
-
sudo += "-g #{sudo_format_user(group)} " if group
|
89
|
-
end
|
90
|
-
|
91
|
-
sudo
|
100
|
+
repo.application.project.sudo_command(owner: owner, group: group)
|
92
101
|
end
|
93
102
|
|
94
103
|
def diff_command(from, to, quiet: false)
|
95
|
-
"diff --binary #{'--quiet' if quiet} #{from}..#{to} #{"--relative=#{cwd}" if cwd} -- #{paths(true)}"
|
104
|
+
"diff --binary #{'--quiet' if quiet} #{from}..#{to} #{"--relative=#{cwd}" if cwd} -- #{paths(true).join(' ')}"
|
96
105
|
end
|
97
106
|
end
|
98
107
|
end
|
data/lib/dapp/git_repo/base.rb
CHANGED
data/lib/dapp/image/argument.rb
CHANGED
@@ -106,7 +106,7 @@ module Dapp
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def service_options
|
109
|
-
{ entrypoint:
|
109
|
+
{ entrypoint: project.bash_path, name: container_name }
|
110
110
|
end
|
111
111
|
|
112
112
|
def prepared_change
|
@@ -118,11 +118,11 @@ module Dapp
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def prepared_bash_command
|
121
|
-
shellout_pack prepared_commands.join(' && ')
|
121
|
+
project.shellout_pack prepared_commands.join(' && ')
|
122
122
|
end
|
123
123
|
|
124
124
|
def prepared_commands
|
125
|
-
return [
|
125
|
+
return [project.true_path] if bash_commands.empty?
|
126
126
|
bash_commands
|
127
127
|
end
|
128
128
|
end
|
data/lib/dapp/image/docker.rb
CHANGED
@@ -3,8 +3,6 @@ module Dapp
|
|
3
3
|
module Image
|
4
4
|
# Docker
|
5
5
|
class Docker
|
6
|
-
include Helper::Shellout
|
7
|
-
|
8
6
|
attr_reader :from
|
9
7
|
attr_reader :name
|
10
8
|
attr_reader :project
|
@@ -16,24 +14,27 @@ module Dapp
|
|
16
14
|
end
|
17
15
|
|
18
16
|
def id
|
19
|
-
|
17
|
+
cache[:id]
|
20
18
|
end
|
21
19
|
|
22
20
|
def untag!
|
23
21
|
raise Error::Build, code: :image_already_untagged, data: { name: name } unless tagged?
|
24
|
-
shellout!("docker rmi #{name}")
|
22
|
+
project.shellout!("docker rmi #{name}")
|
25
23
|
cache_reset
|
26
24
|
end
|
27
25
|
|
28
|
-
def push!
|
26
|
+
def push!
|
29
27
|
raise Error::Build, code: :image_not_exist, data: { name: name } unless tagged?
|
30
|
-
|
28
|
+
project.log_secondary_process(project.t(code: 'process.image_push', data: { name: name })) do
|
29
|
+
project.shellout!("docker push #{name}", log_verbose: true)
|
30
|
+
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def pull!
|
33
|
+
def pull!
|
34
34
|
return if tagged?
|
35
|
-
|
36
|
-
|
35
|
+
project.log_secondary_process(project.t(code: 'process.image_pull', data: { name: name })) do
|
36
|
+
project.shellout!("docker pull #{name}", log_verbose: true)
|
37
|
+
end
|
37
38
|
cache_reset
|
38
39
|
end
|
39
40
|
|
@@ -41,10 +42,6 @@ module Dapp
|
|
41
42
|
!!id
|
42
43
|
end
|
43
44
|
|
44
|
-
def pulled?
|
45
|
-
!!@pulled
|
46
|
-
end
|
47
|
-
|
48
45
|
def created_at
|
49
46
|
raise Error::Build, code: :image_not_exist, data: { name: name } unless tagged?
|
50
47
|
cache[:created_at]
|
@@ -56,7 +53,7 @@ module Dapp
|
|
56
53
|
end
|
57
54
|
|
58
55
|
def self.image_config_option(image_id:, option:)
|
59
|
-
output = shellout!("docker inspect --format='{{json .Config.#{option.to_s.capitalize}}}' #{image_id}").stdout.strip
|
56
|
+
output = Project.shellout!("docker inspect --format='{{json .Config.#{option.to_s.capitalize}}}' #{image_id}").stdout.strip
|
60
57
|
output == 'null' ? [] : JSON.parse(output)
|
61
58
|
end
|
62
59
|
|
@@ -77,8 +74,8 @@ module Dapp
|
|
77
74
|
|
78
75
|
def cache_reset(name = '')
|
79
76
|
cache.delete(name)
|
80
|
-
shellout!("docker images --format='{{.Repository}}:{{.Tag}};{{.ID}};{{.CreatedAt}};{{.Size}}' #{name}").stdout.lines.each do |
|
81
|
-
name, id, created_at, size =
|
77
|
+
Project.shellout!("docker images --format='{{.Repository}}:{{.Tag}};{{.ID}};{{.CreatedAt}};{{.Size}}' --no-trunc #{name}").stdout.lines.each do |l|
|
78
|
+
name, id, created_at, size = l.split(';')
|
82
79
|
cache[name] = { id: id, created_at: created_at, size: size }
|
83
80
|
end
|
84
81
|
end
|