dapp 0.14.11 → 0.14.12
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/lib/dapp/dapp.rb +15 -10
- data/lib/dapp/dapp/deps/base.rb +2 -2
- data/lib/dapp/dapp/deps/gitartifact.rb +2 -2
- data/lib/dapp/dimg/builder/chef.rb +2 -2
- data/lib/dapp/dimg/builder/chef/cookbook.rb +1 -1
- data/lib/dapp/dimg/cli/command/dimg/build.rb +5 -0
- data/lib/dapp/dimg/dapp/command/cleanup.rb +1 -1
- data/lib/dapp/dimg/dapp/command/common.rb +7 -7
- data/lib/dapp/dimg/dapp/command/mrproper.rb +4 -4
- data/lib/dapp/dimg/dapp/command/stages/cleanup_local.rb +5 -5
- data/lib/dapp/dimg/dimg.rb +3 -3
- data/lib/dapp/dimg/git_artifact.rb +68 -35
- data/lib/dapp/dimg/image/docker.rb +8 -8
- data/lib/dapp/dimg/image/stage.rb +3 -3
- data/lib/dapp/kube/dapp/command/chart_create.rb +1 -1
- data/lib/dapp/kube/dapp/command/deploy.rb +2 -2
- data/lib/dapp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13bccb197061f7d78e8f74f498248f6aa2c19833
|
4
|
+
data.tar.gz: d5a9c8d733f8d3f9562d3af9219930220aa78c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca8cf1edb04f43bfac8303ff27696214ce848a013d04c2c19c3e1ffa8f81274032f1e1a533459d1dce5b31a634a191e632b99d96880b9cc9030bef27e27320f9
|
7
|
+
data.tar.gz: b7a031ef19524e04b38cb274d5ddd5261275ffe94591401001eee285a9eff17ac78264ff39de5dc6cef1d1ad658ae95906ba54e265d83c8db7a44c8b7e2fdfbf
|
data/lib/dapp/dapp.rb
CHANGED
@@ -98,21 +98,26 @@ module Dapp
|
|
98
98
|
name
|
99
99
|
end
|
100
100
|
|
101
|
-
def
|
102
|
-
self.class.
|
101
|
+
def host_docker
|
102
|
+
self.class.host_docker
|
103
103
|
end
|
104
104
|
|
105
|
-
def self.
|
106
|
-
@
|
105
|
+
def self.host_docker
|
106
|
+
@host_docker ||= begin
|
107
107
|
raise Error::Dapp, code: :docker_not_found if (res = shellout('which docker')).exitstatus.nonzero?
|
108
|
-
res.stdout.strip
|
109
|
-
current_docker_version = shellout!("#{docker_bin} --version").stdout.strip
|
110
|
-
required_docker_version = '1.10.0'
|
108
|
+
docker_bin = res.stdout.strip
|
111
109
|
|
112
|
-
|
113
|
-
|
114
|
-
|
110
|
+
current_docker_version = shellout!("#{docker_bin} --version").stdout.strip
|
111
|
+
required_docker_version = '1.10.0'
|
112
|
+
|
113
|
+
if Gem::Version.new(required_docker_version) >= Gem::Version.new(current_docker_version[/(\d+\.)+\d+/])
|
114
|
+
raise Error::Dapp, code: :docker_version, data: { version: required_docker_version }
|
115
115
|
end
|
116
|
+
|
117
|
+
[].tap do |cmd|
|
118
|
+
cmd << docker_bin
|
119
|
+
cmd << "--config #{ENV['DAPP_DOCKER_CONFIG']}" if ENV.key?('DAPP_DOCKER_CONFIG')
|
120
|
+
end.join(' ')
|
116
121
|
end
|
117
122
|
end
|
118
123
|
end # Dapp
|
data/lib/dapp/dapp/deps/base.rb
CHANGED
@@ -10,10 +10,10 @@ module Dapp
|
|
10
10
|
|
11
11
|
def base_container
|
12
12
|
@base_container ||= begin
|
13
|
-
if shellout("#{
|
13
|
+
if shellout("#{host_docker} inspect #{base_container_name}").exitstatus.nonzero?
|
14
14
|
log_secondary_process(t(code: 'process.base_container_creating'), short: true) do
|
15
15
|
shellout!(
|
16
|
-
["#{
|
16
|
+
["#{host_docker} create",
|
17
17
|
"--name #{base_container_name}",
|
18
18
|
"--volume /.dapp/deps/base/#{BASE_VERSION} dappdeps/base:#{BASE_VERSION}"].join(' ')
|
19
19
|
)
|
@@ -10,10 +10,10 @@ module Dapp
|
|
10
10
|
|
11
11
|
def gitartifact_container
|
12
12
|
@gitartifact_container ||= begin
|
13
|
-
if shellout("#{
|
13
|
+
if shellout("#{host_docker} inspect #{gitartifact_container_name}").exitstatus.nonzero?
|
14
14
|
log_secondary_process(t(code: 'process.gitartifact_container_creating'), short: true) do
|
15
15
|
shellout!(
|
16
|
-
["#{
|
16
|
+
["#{host_docker} create",
|
17
17
|
"--name #{gitartifact_container_name}",
|
18
18
|
"--volume /.dapp/deps/gitartifact/#{GITARTIFACT_VERSION}",
|
19
19
|
"dappdeps/gitartifact:#{GITARTIFACT_VERSION}"].join(' ')
|
@@ -54,10 +54,10 @@ module Dapp
|
|
54
54
|
|
55
55
|
def chefdk_container
|
56
56
|
@chefdk_container ||= begin
|
57
|
-
if dimg.dapp.shellout("#{dimg.dapp.
|
57
|
+
if dimg.dapp.shellout("#{dimg.dapp.host_docker} inspect #{chefdk_container_name}").exitstatus.nonzero?
|
58
58
|
dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.chefdk_container_creating'), short: true) do
|
59
59
|
dimg.dapp.shellout!(
|
60
|
-
["#{dimg.dapp.
|
60
|
+
["#{dimg.dapp.host_docker} create",
|
61
61
|
"--name #{chefdk_container_name}",
|
62
62
|
"--volume /.dapp/deps/chefdk #{chefdk_image}"].join(' ')
|
63
63
|
)
|
@@ -107,7 +107,7 @@ module Dapp
|
|
107
107
|
]
|
108
108
|
|
109
109
|
builder.dimg.dapp.shellout!(
|
110
|
-
[ "#{builder.dimg.dapp.
|
110
|
+
[ "#{builder.dimg.dapp.host_docker} run --rm",
|
111
111
|
volumes_from.map {|container| "--volumes-from #{container}"}.join(' '),
|
112
112
|
*local_paths.map {|path| "--volume #{path}:#{path}"},
|
113
113
|
"--volume #{builder.dimg.tmp_path}:#{builder.dimg.tmp_path}",
|
@@ -9,7 +9,7 @@ module Dapp
|
|
9
9
|
dapp_containers_flush
|
10
10
|
dapp_dangling_images_flush
|
11
11
|
remove_images_by_query([
|
12
|
-
"#{
|
12
|
+
"#{host_docker} images",
|
13
13
|
%(--format '{{if ne "#{stage_cache}" .Repository }}{{.Repository}}:{{.Tag}}{{ end }}'),
|
14
14
|
%(-f "label=dapp=#{stage_dapp_label}")
|
15
15
|
].join(' ')) # FIXME: negative filter is not currently supported by the Docker CLI
|
@@ -6,19 +6,19 @@ module Dapp
|
|
6
6
|
protected
|
7
7
|
|
8
8
|
def dapp_images_names
|
9
|
-
shellout!(%(#{
|
9
|
+
shellout!(%(#{host_docker} images --format="{{.Repository}}:{{.Tag}}" #{stage_cache})).stdout.lines.map(&:strip)
|
10
10
|
end
|
11
11
|
|
12
12
|
def dapp_images_ids
|
13
|
-
shellout!(%(#{
|
13
|
+
shellout!(%(#{host_docker} images #{stage_cache} -q --no-trunc)).stdout.lines.map(&:strip)
|
14
14
|
end
|
15
15
|
|
16
16
|
def dapp_containers_flush
|
17
|
-
remove_containers_by_query(%(#{
|
17
|
+
remove_containers_by_query(%(#{host_docker} ps -a -f "label=dapp" -f "name=#{container_name_prefix}" -q), force: true)
|
18
18
|
end
|
19
19
|
|
20
20
|
def dapp_dangling_images_flush
|
21
|
-
remove_images_by_query(%(#{
|
21
|
+
remove_images_by_query(%(#{host_docker} images -f "dangling=true" -f "label=dapp=#{stage_dapp_label}" -q), force: true)
|
22
22
|
end
|
23
23
|
|
24
24
|
def remove_images_by_query(images_query, force: false)
|
@@ -28,13 +28,13 @@ module Dapp
|
|
28
28
|
def remove_images(ids, force: false)
|
29
29
|
ids.uniq!
|
30
30
|
check_user_containers!(ids) unless force
|
31
|
-
remove_base("#{
|
31
|
+
remove_base("#{host_docker} rmi%{force_option} %{ids}", ids, force: force)
|
32
32
|
end
|
33
33
|
|
34
34
|
def check_user_containers!(images_ids)
|
35
35
|
return if images_ids.empty?
|
36
36
|
log_step_with_indent(:'check user containers') do
|
37
|
-
run_command(%(#{
|
37
|
+
run_command(%(#{host_docker} ps -a -q #{images_ids.uniq.map { |image_id| "--filter=ancestor=#{image_id}" }.join(' ')})).tap do |res|
|
38
38
|
raise Error::Command, code: :user_containers_detected, data: { ids: res.stdout.strip } if res && !res.stdout.strip.empty? && !dry_run?
|
39
39
|
end
|
40
40
|
end
|
@@ -45,7 +45,7 @@ module Dapp
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def remove_containers(ids, force: false)
|
48
|
-
remove_base("#{
|
48
|
+
remove_base("#{host_docker} rm%{force_option} %{ids}", ids.uniq, force: force)
|
49
49
|
end
|
50
50
|
|
51
51
|
def remove_base(query_format, ids, force: false)
|
@@ -45,11 +45,11 @@ module Dapp
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def dapp_containers_flush_by_label(label)
|
48
|
-
remove_containers_by_query(%(#{
|
48
|
+
remove_containers_by_query(%(#{host_docker} ps -a -f "label=#{label}" -q), force: true)
|
49
49
|
end
|
50
50
|
|
51
51
|
def dapp_dangling_images_flush_by_label(label)
|
52
|
-
remove_images_by_query(%(#{
|
52
|
+
remove_images_by_query(%(#{host_docker} images -f "dangling=true" -f "label=#{label}" -q), force: true)
|
53
53
|
end
|
54
54
|
|
55
55
|
def dapp_images_flush_by_label(label)
|
@@ -59,7 +59,7 @@ module Dapp
|
|
59
59
|
|
60
60
|
def dapp_images_by_label(label)
|
61
61
|
@dapp_images ||= begin
|
62
|
-
shellout!(%(#{
|
62
|
+
shellout!(%(#{host_docker} images -f "dangling=false" --format="{{.Repository}}:{{.Tag}}" -f "label=#{label}"))
|
63
63
|
.stdout
|
64
64
|
.lines
|
65
65
|
.map(&:strip)
|
@@ -68,7 +68,7 @@ module Dapp
|
|
68
68
|
|
69
69
|
def proper_cache_all_images
|
70
70
|
shellout!([
|
71
|
-
"#{
|
71
|
+
"#{host_docker} images",
|
72
72
|
'--format="{{.Repository}}:{{.Tag}}"',
|
73
73
|
%(-f "label=dapp-cache-version=#{::Dapp::BUILD_CACHE_VERSION}" -f "dangling=false")
|
74
74
|
].join(' ')).stdout.lines.map(&:strip)
|
@@ -51,7 +51,7 @@ module Dapp
|
|
51
51
|
def actual_cache_images
|
52
52
|
@actual_cache_images ||= begin
|
53
53
|
shellout!([
|
54
|
-
"#{
|
54
|
+
"#{host_docker} images",
|
55
55
|
'--format="{{.Repository}}:{{.Tag}}"',
|
56
56
|
%(-f "label=dapp-cache-version=#{::Dapp::BUILD_CACHE_VERSION}"),
|
57
57
|
stage_cache
|
@@ -60,7 +60,7 @@ module Dapp
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def dapp_images_hash
|
63
|
-
shellout!(%(#{
|
63
|
+
shellout!(%(#{host_docker} images --format "{{.Repository}}:{{.Tag}};{{.ID}}" --no-trunc #{stage_cache})).stdout.lines.map do |line|
|
64
64
|
line.strip.split(';')
|
65
65
|
end.to_h
|
66
66
|
end
|
@@ -79,7 +79,7 @@ module Dapp
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def image_exist?(image_id)
|
82
|
-
shellout!(%(#{
|
82
|
+
shellout!(%(#{host_docker} inspect #{image_id}))
|
83
83
|
true
|
84
84
|
rescue ::Dapp::Error::Shellout
|
85
85
|
false
|
@@ -90,7 +90,7 @@ module Dapp
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def image_parent(image_id)
|
93
|
-
shellout!(%(#{
|
93
|
+
shellout!(%(#{host_docker} inspect -f {{.Parent}} #{image_id})).stdout.strip
|
94
94
|
end
|
95
95
|
|
96
96
|
def proper_git_commit
|
@@ -109,7 +109,7 @@ module Dapp
|
|
109
109
|
def dapp_images_detailed
|
110
110
|
@dapp_images_detailed ||= {}.tap do |images|
|
111
111
|
dapp_images_names.each do |image_name|
|
112
|
-
shellout!(%(#{
|
112
|
+
shellout!(%(#{host_docker} inspect --format='{{json .}}' #{image_name})).stdout.strip.tap do |output|
|
113
113
|
images[image_name] = output == 'null' ? {} : JSON.parse(output)
|
114
114
|
end
|
115
115
|
end
|
data/lib/dapp/dimg/dimg.rb
CHANGED
@@ -120,7 +120,7 @@ module Dapp
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def run(docker_options, command)
|
123
|
-
cmd = "#{dapp.
|
123
|
+
cmd = "#{dapp.host_docker} run #{[docker_options, last_stage.image.built_id, command].flatten.compact.join(' ')}"
|
124
124
|
if dapp.dry_run?
|
125
125
|
dapp.log(cmd)
|
126
126
|
else
|
@@ -157,7 +157,7 @@ module Dapp
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def introspect_image!(image:, options:)
|
160
|
-
cmd = "#{dapp.
|
160
|
+
cmd = "#{dapp.host_docker} run -ti --rm --entrypoint #{dapp.bash_bin} #{options} #{image}"
|
161
161
|
system(cmd)
|
162
162
|
end
|
163
163
|
|
@@ -167,7 +167,7 @@ module Dapp
|
|
167
167
|
# Чтобы от них избавиться — запускаем docker-контейнер под root-пользователем
|
168
168
|
# и удаляем примонтированную tmp-директорию.
|
169
169
|
cmd = "".tap do |cmd|
|
170
|
-
cmd << "#{dapp.
|
170
|
+
cmd << "#{dapp.host_docker} run --rm"
|
171
171
|
cmd << " --volume #{dapp.tmp_base_dir}:#{dapp.tmp_base_dir}"
|
172
172
|
cmd << " alpine:3.6"
|
173
173
|
cmd << " rm -rf #{tmp_path}"
|
@@ -67,13 +67,13 @@ module Dapp
|
|
67
67
|
when :directory
|
68
68
|
stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'directory'
|
69
69
|
|
70
|
-
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
|
71
|
-
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C #{to}"
|
70
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
|
71
|
+
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C \"#{to}\""
|
72
72
|
when :file
|
73
73
|
stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'file'
|
74
74
|
|
75
|
-
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
|
76
|
-
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C #{File.dirname(to)}"
|
75
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
|
76
|
+
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C \"#{File.dirname(to)}\""
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -89,14 +89,14 @@ module Dapp
|
|
89
89
|
if any_changes?(*dev_patch_stage_commits(stage))
|
90
90
|
case archive_type
|
91
91
|
when :directory
|
92
|
-
changed_files = diff_patches(*dev_patch_stage_commits(stage)).map {|p| File.join(to, cwd, p.delta.new_file[:path])}
|
92
|
+
changed_files = diff_patches(*dev_patch_stage_commits(stage)).map {|p| "\"#{File.join(to, cwd, p.delta.new_file[:path])}\""}
|
93
93
|
commands << "#{repo.dimg.dapp.rm_bin} -rf #{changed_files.join(' ')}"
|
94
|
-
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
|
95
|
-
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C #{to}"
|
94
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
|
95
|
+
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C \"#{to}\""
|
96
96
|
when :file
|
97
|
-
commands << "#{repo.dimg.dapp.rm_bin} -rf #{to}"
|
98
|
-
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
|
99
|
-
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C #{File.dirname(to)}"
|
97
|
+
commands << "#{repo.dimg.dapp.rm_bin} -rf \"#{to}\""
|
98
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
|
99
|
+
commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C \"#{File.dirname(to)}\""
|
100
100
|
else
|
101
101
|
raise
|
102
102
|
end
|
@@ -105,11 +105,11 @@ module Dapp
|
|
105
105
|
if patch_any_changes?(stage)
|
106
106
|
case archive_type
|
107
107
|
when :directory
|
108
|
-
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
|
109
|
-
commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory
|
108
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
|
109
|
+
commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=\"#{to}\" --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
|
110
110
|
when :file
|
111
|
-
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
|
112
|
-
commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory
|
111
|
+
commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
|
112
|
+
commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=\"#{File.dirname(to)}\" --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
|
113
113
|
else
|
114
114
|
raise
|
115
115
|
end
|
@@ -213,33 +213,65 @@ module Dapp
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def archive_file(stage, from_commit, to_commit)
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
File.read(path)
|
224
|
-
else
|
225
|
-
repo.lookup_object(entry[:oid]).content
|
226
|
-
end
|
227
|
-
end
|
216
|
+
if repo.dimg.dapp.options[:use_system_tar]
|
217
|
+
archive_file_with_system_tar(stage, from_commit, to_commit)
|
218
|
+
else
|
219
|
+
archive_file_with_tar_writer(stage, from_commit, to_commit)
|
220
|
+
end
|
221
|
+
repo.dimg.container_tmp_path('archives', archive_file_name(from_commit, to_commit))
|
222
|
+
end
|
228
223
|
|
229
|
-
|
230
|
-
|
224
|
+
def archive_file_with_tar_writer(stage, from_commit, to_commit)
|
225
|
+
tar_write(repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit))) do |tar|
|
226
|
+
archive_diff_pathes(stage,from_commit, to_commit) do |path, content, mode|
|
227
|
+
if mode == 40960 # symlink
|
228
|
+
tar.add_symlink path, content, mode
|
231
229
|
else
|
232
|
-
tar.add_file
|
230
|
+
tar.add_file path, mode do |tf|
|
233
231
|
tf.write content
|
234
232
|
end
|
235
233
|
end
|
236
234
|
end
|
237
235
|
end
|
238
|
-
repo.dimg.container_tmp_path('archives', archive_file_name(from_commit, to_commit))
|
239
236
|
rescue Gem::Package::TooLongFileName => e
|
240
237
|
raise Error::TarWriter, message: e.message
|
241
238
|
end
|
242
239
|
|
240
|
+
def archive_file_with_system_tar(stage, from_commit, to_commit)
|
241
|
+
repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit)).tap do |archive_path|
|
242
|
+
relative_archive_file_path = File.join('archives_files', file_name(from_commit, to_commit))
|
243
|
+
archive_diff_pathes(stage, from_commit, to_commit) do |path, content, mode|
|
244
|
+
file_path = repo.dimg.tmp_path(relative_archive_file_path, path)
|
245
|
+
|
246
|
+
if mode == 40960 # symlink
|
247
|
+
FileUtils.symlink(content, file_path)
|
248
|
+
else
|
249
|
+
IO.write(file_path, content)
|
250
|
+
FileUtils.chmod(mode, file_path)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
repo.dimg.dapp.shellout!("tar -C #{repo.dimg.tmp_path(relative_archive_file_path)} -cf #{archive_path} .")
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def archive_diff_pathes(stage, from_commit, to_commit)
|
259
|
+
diff_patches(from_commit, to_commit).each do |patch|
|
260
|
+
entry = patch.delta.new_file
|
261
|
+
|
262
|
+
content = begin
|
263
|
+
if to_commit == nil
|
264
|
+
next unless (path = repo.path.dirname.join(entry[:path])).file?
|
265
|
+
File.read(path)
|
266
|
+
else
|
267
|
+
repo.lookup_object(entry[:oid]).content
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
yield slice_cwd(stage, entry[:path]), content, entry[:mode]
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
243
275
|
def slice_cwd(stage, path)
|
244
276
|
return path if cwd.empty?
|
245
277
|
|
@@ -248,6 +280,7 @@ module Dapp
|
|
248
280
|
path
|
249
281
|
.reverse
|
250
282
|
.chomp(cwd.reverse)
|
283
|
+
.chomp('/')
|
251
284
|
.reverse
|
252
285
|
when :file
|
253
286
|
File.basename(to)
|
@@ -257,7 +290,7 @@ module Dapp
|
|
257
290
|
end
|
258
291
|
|
259
292
|
def archive_file_name(from_commit, to_commit)
|
260
|
-
file_name(from_commit, to_commit, 'tar')
|
293
|
+
file_name(from_commit, to_commit, ext: 'tar')
|
261
294
|
end
|
262
295
|
|
263
296
|
def patch_file(stage, from_commit, to_commit)
|
@@ -271,7 +304,7 @@ module Dapp
|
|
271
304
|
def change_patch_new_file_path(stage, patch)
|
272
305
|
patch.to_s.lines.tap do |lines|
|
273
306
|
modify_patch_line = proc do |line_number, path_char|
|
274
|
-
action_part, path_part = lines[line_number].split
|
307
|
+
action_part, path_part = lines[line_number].strip.split(' ', 2)
|
275
308
|
if (path_with_cwd = path_part.partition("#{path_char}/").last).start_with?(cwd)
|
276
309
|
native_path = case archive_type
|
277
310
|
when :directory
|
@@ -321,11 +354,11 @@ module Dapp
|
|
321
354
|
end
|
322
355
|
|
323
356
|
def patch_file_name(from_commit, to_commit)
|
324
|
-
file_name(from_commit, to_commit, 'patch')
|
357
|
+
file_name(from_commit, to_commit, ext: 'patch')
|
325
358
|
end
|
326
359
|
|
327
|
-
def file_name(*args, ext)
|
328
|
-
"#{[paramshash, args].flatten.compact.join('_')}.#{ext}"
|
360
|
+
def file_name(*args, ext: nil)
|
361
|
+
"#{[paramshash, args].flatten.compact.join('_')}#{".#{ext}" unless ext.nil? }"
|
329
362
|
end
|
330
363
|
|
331
364
|
def diff_patches(from_commit, to_commit, paths: include_paths_or_cwd)
|
@@ -22,21 +22,21 @@ module Dapp
|
|
22
22
|
|
23
23
|
def untag!
|
24
24
|
raise Error::Build, code: :image_already_untagged, data: { name: name } unless tagged?
|
25
|
-
dapp.shellout!("#{dapp.
|
25
|
+
dapp.shellout!("#{dapp.host_docker} rmi #{name}")
|
26
26
|
cache_reset
|
27
27
|
end
|
28
28
|
|
29
29
|
def push!
|
30
30
|
raise Error::Build, code: :image_not_exist, data: { name: name } unless tagged?
|
31
31
|
dapp.log_secondary_process(dapp.t(code: 'process.image_push', data: { name: name })) do
|
32
|
-
dapp.shellout!("#{dapp.
|
32
|
+
dapp.shellout!("#{dapp.host_docker} push #{name}", verbose: true)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def pull!
|
37
37
|
return if tagged?
|
38
38
|
dapp.log_secondary_process(dapp.t(code: 'process.image_pull', data: { name: name })) do
|
39
|
-
dapp.shellout!("#{dapp.
|
39
|
+
dapp.shellout!("#{dapp.host_docker} pull #{name}", verbose: true)
|
40
40
|
end
|
41
41
|
cache_reset
|
42
42
|
end
|
@@ -56,7 +56,7 @@ module Dapp
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.image_config_option(image_id:, option:)
|
59
|
-
output = ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.
|
59
|
+
output = ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} inspect --format='{{json .Config.#{option.to_s.capitalize}}}' #{image_id}").stdout.strip
|
60
60
|
output == 'null' ? [] : JSON.parse(output)
|
61
61
|
end
|
62
62
|
|
@@ -88,17 +88,17 @@ module Dapp
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def tag!(id:, tag:, verbose: false, quiet: false)
|
91
|
-
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.
|
91
|
+
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} tag #{id} #{tag}", verbose: verbose, quiet: quiet)
|
92
92
|
cache_reset
|
93
93
|
end
|
94
94
|
|
95
95
|
def save!(image_or_images, file_path, verbose: false, quiet: false)
|
96
96
|
images = Array(image_or_images).join(' ')
|
97
|
-
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.
|
97
|
+
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} save -o #{file_path} #{images}", verbose: verbose, quiet: quiet)
|
98
98
|
end
|
99
99
|
|
100
100
|
def load!(file_path, verbose: false, quiet: false)
|
101
|
-
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.
|
101
|
+
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} load -i #{file_path}", verbose: verbose, quiet: quiet)
|
102
102
|
end
|
103
103
|
|
104
104
|
def cache
|
@@ -107,7 +107,7 @@ module Dapp
|
|
107
107
|
|
108
108
|
def cache_reset(name = '')
|
109
109
|
cache.delete(name)
|
110
|
-
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.
|
110
|
+
::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} images --format='{{.Repository}}:{{.Tag}};{{.ID}};{{.CreatedAt}};{{.Size}}' --no-trunc #{name}")
|
111
111
|
.stdout
|
112
112
|
.lines
|
113
113
|
.each do |l|
|
@@ -25,7 +25,7 @@ module Dapp
|
|
25
25
|
run!
|
26
26
|
@built_id = commit!
|
27
27
|
ensure
|
28
|
-
dapp.shellout("#{dapp.
|
28
|
+
dapp.shellout("#{dapp.host_docker} rm #{container_name}")
|
29
29
|
end
|
30
30
|
|
31
31
|
def built?
|
@@ -70,7 +70,7 @@ module Dapp
|
|
70
70
|
|
71
71
|
def run!
|
72
72
|
raise Error::Build, code: :built_id_not_defined if from.built_id.nil?
|
73
|
-
dapp.shellout!("#{dapp.
|
73
|
+
dapp.shellout!("#{dapp.host_docker} run #{prepared_options} #{from.built_id} -ec '#{prepared_bash_command}'", verbose: true)
|
74
74
|
rescue ::Dapp::Error::Shellout => error
|
75
75
|
dapp.log_warning(desc: { code: :launched_command, data: { command: prepared_commands.join(' && ') }, context: :container })
|
76
76
|
|
@@ -83,7 +83,7 @@ module Dapp
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def commit!
|
86
|
-
dapp.shellout!("#{dapp.
|
86
|
+
dapp.shellout!("#{dapp.host_docker} commit #{prepared_change} #{container_name}").stdout.strip
|
87
87
|
end
|
88
88
|
|
89
89
|
def clone!(name)
|
@@ -64,7 +64,7 @@ spec:
|
|
64
64
|
secretName: {{ .Chart.Name }}-backend
|
65
65
|
containers:
|
66
66
|
- command: [ '/bin/bash', '-l', '-c', 'bundle exec ctl start' ]
|
67
|
-
image: {{ tuple .
|
67
|
+
image: {{ tuple "specific-name" . | include "dimg" }} # or nameless dimg {{ tuple . | include "dimg" }}
|
68
68
|
imagePullPolicy: Always
|
69
69
|
name: {{ .Chart.Name }}-backend
|
70
70
|
livenessProbe:
|
@@ -79,10 +79,10 @@ module Dapp
|
|
79
79
|
{{- if (ge (len (index .)) 2) -}}
|
80
80
|
{{- $name := index . 0 -}}
|
81
81
|
{{- $context := index . 1 -}}
|
82
|
-
{{- printf "%
|
82
|
+
{{- printf "%v:%v-%v" $context.Values.global.dapp.repo $name $context.Values.global.dapp.image_version -}}
|
83
83
|
{{- else -}}
|
84
84
|
{{- $context := index . 0 -}}
|
85
|
-
{{- printf "%
|
85
|
+
{{- printf "%v:%v" $context.Values.global.dapp.repo $context.Values.global.dapp.image_version -}}
|
86
86
|
{{- end -}}
|
87
87
|
{{- end -}}
|
88
88
|
|
data/lib/dapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|