dapp 0.7.11 → 0.7.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/en/common.yml +4 -4
- data/lib/dapp.rb +2 -0
- data/lib/dapp/build/stage/artifact_base.rb +1 -1
- data/lib/dapp/build/stage/artifact_default.rb +6 -6
- data/lib/dapp/build/stage/import_artifact.rb +1 -1
- data/lib/dapp/builder/chef.rb +16 -16
- data/lib/dapp/dimg.rb +2 -1
- data/lib/dapp/dimg/system_shellout.rb +17 -0
- data/lib/dapp/git_artifact.rb +5 -5
- data/lib/dapp/git_repo/base.rb +1 -1
- data/lib/dapp/helper/trivia.rb +10 -0
- data/lib/dapp/image/argument.rb +2 -2
- data/lib/dapp/image/scratch.rb +3 -2
- data/lib/dapp/project.rb +23 -6
- data/lib/dapp/project/dappfile.rb +1 -11
- data/lib/dapp/project/deps/base.rb +4 -4
- data/lib/dapp/project/deps/gitartifact.rb +2 -2
- data/lib/dapp/project/system_shellout.rb +35 -71
- data/lib/dapp/version.rb +1 -1
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e413ad01ef18d652b7dbda03c0b68ebbd62b1d0
|
4
|
+
data.tar.gz: 207e309aedd9d439e673fbaabdfc1e50cb9a5a10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9dfe160397e55ec631e6e2b3bd471308e45d64c62bb54b504d9a1e88a024a664844b99958431d7c13b6ec11b51be0ab6d70cadb72a0364f453ec1ecb1f5243f
|
7
|
+
data.tar.gz: 9b6b84bcc8f0f62b0d1c0c503eafc9607a57e350123d3f4999b6498f8d94e3d9cb422c949599b6af2d093effe4dbe51a5ef789ce3201de157c70ffab09f52546
|
data/config/en/common.yml
CHANGED
@@ -18,10 +18,10 @@ en:
|
|
18
18
|
berks_vendor: 'vendoring cookbooks'
|
19
19
|
chef_cookbooks_stage_berks_vendor: 'vendoring cookbooks for chef cookbooks stage'
|
20
20
|
waiting_resouce_lock: "waiting for locked resource '%{name}'"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
gitartifact_container_creating: 'creating dappdeps/gitartifact container'
|
22
|
+
base_container_creating: 'creating dappdeps/base container'
|
23
|
+
chefdk_container_creating: 'creating dappdeps/chefdk container'
|
24
|
+
system_shellout_container_starting: 'starting system-shellout container'
|
25
25
|
image_pull: "pulling image '%{name}'"
|
26
26
|
image_push: "pushing image '%{name}'"
|
27
27
|
status:
|
data/lib/dapp.rb
CHANGED
@@ -13,6 +13,7 @@ require 'ostruct'
|
|
13
13
|
require 'time'
|
14
14
|
require 'i18n'
|
15
15
|
require 'paint'
|
16
|
+
require 'inifile'
|
16
17
|
|
17
18
|
require 'net_status'
|
18
19
|
|
@@ -157,6 +158,7 @@ require 'dapp/dimg/git_artifact'
|
|
157
158
|
require 'dapp/dimg/path'
|
158
159
|
require 'dapp/dimg/tags'
|
159
160
|
require 'dapp/dimg/stages'
|
161
|
+
require 'dapp/dimg/system_shellout'
|
160
162
|
require 'dapp/dimg'
|
161
163
|
require 'dapp/artifact'
|
162
164
|
require 'dapp/image/argument'
|
@@ -65,7 +65,7 @@ module Dapp
|
|
65
65
|
docker_options = ['--rm',
|
66
66
|
"--volume #{dimg.tmp_path('artifact', artifact_name)}:#{artifact_dimg.container_tmp_path(artifact_name)}",
|
67
67
|
"--volumes-from #{dimg.project.base_container}",
|
68
|
-
"--entrypoint #{dimg.project.
|
68
|
+
"--entrypoint #{dimg.project.bash_bin}"]
|
69
69
|
dimg.project.log_secondary_process(dimg.project.t(code: 'process.artifact_copy',
|
70
70
|
data: { name: artifact_name }),
|
71
71
|
short: true,
|
@@ -39,18 +39,18 @@ module Dapp
|
|
39
39
|
copy_files = proc do |from_, cwd_, path_ = ''|
|
40
40
|
cwd_ = File.expand_path(File.join('/', cwd_))
|
41
41
|
"if [[ -d #{File.join(from_, cwd_, path_)} ]]; then " \
|
42
|
-
"#{dimg.project.
|
43
|
-
"#{dimg.project.
|
42
|
+
"#{dimg.project.find_bin} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec " \
|
43
|
+
"#{dimg.project.bash_bin} -ec '#{dimg.project.install_bin} -D #{credentials} {} " \
|
44
44
|
"#{File.join(to, '$(echo {} | ' \
|
45
|
-
"#{dimg.project.
|
45
|
+
"#{dimg.project.sed_bin} -e \"s/#{File.join(from_, cwd_).gsub('/', '\\/')}//g\")")}' \\; ;" \
|
46
46
|
'fi'
|
47
47
|
end
|
48
48
|
|
49
49
|
commands = []
|
50
|
-
commands << [dimg.project.
|
50
|
+
commands << [dimg.project.install_bin, credentials, '-d', to].join(' ')
|
51
51
|
commands.concat(include_paths.empty? ? Array(copy_files.call(from, cwd)) : include_paths.map { |path| copy_files.call(from, cwd, path) })
|
52
|
-
commands << "#{dimg.project.
|
53
|
-
"#{dimg.project.
|
52
|
+
commands << "#{dimg.project.find_bin} #{to} -type d -exec " \
|
53
|
+
"#{dimg.project.bash_bin} -ec '#{dimg.project.install_bin} -d #{credentials} {}' \\;"
|
54
54
|
commands.join(' && ')
|
55
55
|
end
|
56
56
|
# rubocop:enable Metrics/ParameterLists, Metrics/AbcSize, Metrics/MethodLength
|
@@ -57,7 +57,7 @@ module Dapp
|
|
57
57
|
end
|
58
58
|
include_paths.map! { |path| path[1..-1] } # relative path
|
59
59
|
|
60
|
-
command = "#{sudo} #{dimg.project.
|
60
|
+
command = "#{sudo} #{dimg.project.tar_bin} -czf #{container_archive_path} #{exclude_paths} #{include_paths.join(' ')} #{credentials}"
|
61
61
|
run_artifact_dimg(artifact_dimg, artifact_name, command)
|
62
62
|
|
63
63
|
image.add_archive archive_path
|
data/lib/dapp/builder/chef.rb
CHANGED
@@ -40,8 +40,8 @@ module Dapp
|
|
40
40
|
def chef_cookbooks(image)
|
41
41
|
image.add_volume "#{cookbooks_vendor_path(chef_cookbooks_stage: true)}:#{dimg.container_dapp_path('chef_cookbooks')}"
|
42
42
|
image.add_command(
|
43
|
-
"#{dimg.project.
|
44
|
-
["#{dimg.project.
|
43
|
+
"#{dimg.project.mkdir_bin} -p /usr/share/dapp/chef_repo",
|
44
|
+
["#{dimg.project.cp_bin} -a #{dimg.container_dapp_path('chef_cookbooks')} ",
|
45
45
|
'/usr/share/dapp/chef_repo/cookbooks'].join
|
46
46
|
)
|
47
47
|
end
|
@@ -208,7 +208,7 @@ module Dapp
|
|
208
208
|
def chefdk_container
|
209
209
|
@chefdk_container ||= begin
|
210
210
|
if dimg.project.shellout("docker inspect #{chefdk_container_name}").exitstatus.nonzero?
|
211
|
-
dimg.project.log_secondary_process(dimg.project.t(code: 'process.
|
211
|
+
dimg.project.log_secondary_process(dimg.project.t(code: 'process.chefdk_container_creating'), short: true) do
|
212
212
|
dimg.project.shellout!(
|
213
213
|
['docker create',
|
214
214
|
"--name #{chefdk_container_name}",
|
@@ -253,13 +253,13 @@ module Dapp
|
|
253
253
|
after_vendor_commands = [].tap do |commands|
|
254
254
|
if dimg.project.dev_mode?
|
255
255
|
commands.push(
|
256
|
-
["#{dimg.project.
|
257
|
-
"--mode $(#{dimg.project.
|
256
|
+
["#{dimg.project.install_bin} -o #{Process.uid} -g #{Process.gid} ",
|
257
|
+
"--mode $(#{dimg.project.stat_bin} -c %a Berksfile.lock) ",
|
258
258
|
"Berksfile.lock #{berksfile_lock_path}"].join
|
259
259
|
)
|
260
260
|
elsif !chef_cookbooks_stage
|
261
261
|
commands.push(
|
262
|
-
"export LOCKDIFF=$(#{dimg.project.
|
262
|
+
"export LOCKDIFF=$(#{dimg.project.diff_bin} -u1 #{berksfile_lock_path} Berksfile.lock)",
|
263
263
|
['if [ "$LOCKDIFF" != "" ] ; then ',
|
264
264
|
"echo -e \"",
|
265
265
|
"Bad Berksfile.lock, run '#{_update_berksfile_lock_cmd}' ",
|
@@ -271,14 +271,14 @@ module Dapp
|
|
271
271
|
end
|
272
272
|
|
273
273
|
vendor_commands = [
|
274
|
-
"#{dimg.project.
|
274
|
+
"#{dimg.project.mkdir_bin} -p ~/.ssh",
|
275
275
|
"echo \"Host *\" >> ~/.ssh/config",
|
276
276
|
"echo \" StrictHostKeyChecking no\" >> ~/.ssh/config",
|
277
277
|
*berksfile
|
278
278
|
.local_cookbooks
|
279
279
|
.values
|
280
280
|
.map {|cookbook|
|
281
|
-
["#{dimg.project.
|
281
|
+
["#{dimg.project.rsync_bin} --archive",
|
282
282
|
#*cookbook[:chefignore].map {|path| "--exclude #{path}"}, # FIXME
|
283
283
|
"--relative #{cookbook[:path]} /tmp/local_cookbooks",
|
284
284
|
].join(' ')
|
@@ -287,13 +287,13 @@ module Dapp
|
|
287
287
|
*before_vendor_commands,
|
288
288
|
'/.dapp/deps/chefdk/bin/berks vendor /tmp/cookbooks',
|
289
289
|
*after_vendor_commands,
|
290
|
-
["#{dimg.project.
|
291
|
-
"#{dimg.project.
|
292
|
-
"#{dest_path}/$(echo {} | #{dimg.project.
|
293
|
-
["#{dimg.project.
|
294
|
-
"#{dimg.project.
|
295
|
-
"#{dest_path}/$(echo {} | #{dimg.project.
|
296
|
-
"#{dimg.project.
|
290
|
+
["#{dimg.project.find_bin} /tmp/cookbooks -type d -exec #{dimg.project.bash_bin} -ec '",
|
291
|
+
"#{dimg.project.install_bin} -o #{Process.uid} -g #{Process.gid} --mode $(#{dimg.project.stat_bin} -c %a {}) -d ",
|
292
|
+
"#{dest_path}/$(echo {} | #{dimg.project.sed_bin} -e \"s/^\\/tmp\\/cookbooks//\")' \\;"].join,
|
293
|
+
["#{dimg.project.find_bin} /tmp/cookbooks -type f -exec #{dimg.project.bash_bin} -ec '",
|
294
|
+
"#{dimg.project.install_bin} -o #{Process.uid} -g #{Process.gid} --mode $(#{dimg.project.stat_bin} -c %a {}) {} ",
|
295
|
+
"#{dest_path}/$(echo {} | #{dimg.project.sed_bin} -e \"s/\\/tmp\\/cookbooks//\")' \\;"].join,
|
296
|
+
"#{dimg.project.install_bin} -o #{Process.uid} -g #{Process.gid} --mode 0644 <(#{dimg.project.date_bin} +%s.%N) #{dest_path.join('.created_at')}"
|
297
297
|
]
|
298
298
|
|
299
299
|
dimg.project.shellout!(
|
@@ -307,7 +307,7 @@ module Dapp
|
|
307
307
|
"--volume #{dest_path.tap(&:mkpath)}:#{dest_path}",
|
308
308
|
('--env SSH_AUTH_SOCK=/tmp/dapp-ssh-agent' if dimg.project.ssh_auth_sock),
|
309
309
|
('--env DAPP_CHEF_COOKBOOKS_VENDORING=1' if chef_cookbooks_stage),
|
310
|
-
"dappdeps/berksdeps:0.1.0 #{dimg.project.
|
310
|
+
"dappdeps/berksdeps:0.1.0 #{dimg.project.bash_bin} -ec '#{dimg.project.shellout_pack(vendor_commands.join(' && '))}'"].compact.join(' '),
|
311
311
|
log_verbose: dimg.project.log_verbose?
|
312
312
|
)
|
313
313
|
end
|
data/lib/dapp/dimg.rb
CHANGED
@@ -5,6 +5,7 @@ module Dapp
|
|
5
5
|
include Path
|
6
6
|
include Tags
|
7
7
|
include Stages
|
8
|
+
include SystemShellout
|
8
9
|
|
9
10
|
include Helper::Sha256
|
10
11
|
|
@@ -148,7 +149,7 @@ module Dapp
|
|
148
149
|
end
|
149
150
|
|
150
151
|
def introspect_image!(image:, options:)
|
151
|
-
cmd = "docker run -ti --rm --entrypoint #{project.
|
152
|
+
cmd = "docker run -ti --rm --entrypoint #{project.bash_bin} #{options} #{image}"
|
152
153
|
system(cmd)
|
153
154
|
end
|
154
155
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Dapp
|
2
|
+
# Dimg
|
3
|
+
class Dimg
|
4
|
+
# SystemShellout
|
5
|
+
module SystemShellout
|
6
|
+
def system_shellout(command, **kwargs)
|
7
|
+
project.system_shellout_extra(volume: tmp_path) do
|
8
|
+
project.system_shellout(command, **kwargs)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def system_shellout!(command, **kwargs)
|
13
|
+
system_shellout(command, raise_error: true, **kwargs)
|
14
|
+
end
|
15
|
+
end # SystemShellout
|
16
|
+
end # Dimg
|
17
|
+
end # Dapp
|
data/lib/dapp/git_artifact.rb
CHANGED
@@ -26,9 +26,9 @@ module Dapp
|
|
26
26
|
def apply_archive_command(stage)
|
27
27
|
credentials = [:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
|
28
28
|
|
29
|
-
["#{repo.dimg.project.
|
30
|
-
["#{repo.dimg.project.
|
31
|
-
"#{sudo}#{repo.dimg.project.
|
29
|
+
["#{repo.dimg.project.install_bin} #{credentials.join(' ')} -d #{to}",
|
30
|
+
["#{repo.dimg.project.git_bin} --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{include_paths.join(' ')}",
|
31
|
+
"#{sudo}#{repo.dimg.project.tar_bin} -x -C #{to} #{archive_command_excludes.join(' ')}"].join(' | ')]
|
32
32
|
end
|
33
33
|
|
34
34
|
def apply_patch_command(stage)
|
@@ -36,8 +36,8 @@ module Dapp
|
|
36
36
|
prev_commit = stage.prev_g_a_stage.layer_commit(self)
|
37
37
|
|
38
38
|
if prev_commit != current_commit || any_changes?(prev_commit, current_commit)
|
39
|
-
[["#{repo.dimg.project.
|
40
|
-
"#{sudo}#{repo.dimg.project.
|
39
|
+
[["#{repo.dimg.project.git_bin} --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
|
40
|
+
"#{sudo}#{repo.dimg.project.git_bin} apply --whitespace=nowarn --directory=#{to} #{patch_command_excludes.join(' ')} --unsafe-paths"].join(' | ')]
|
41
41
|
else
|
42
42
|
[]
|
43
43
|
end
|
data/lib/dapp/git_repo/base.rb
CHANGED
data/lib/dapp/helper/trivia.rb
CHANGED
@@ -15,6 +15,16 @@ module Dapp
|
|
15
15
|
path.delete if path.exist?
|
16
16
|
end
|
17
17
|
|
18
|
+
def search_file_upward(filename)
|
19
|
+
cdir = Pathname(work_dir)
|
20
|
+
loop do
|
21
|
+
if (path = cdir.join(filename)).exist?
|
22
|
+
return path.to_s
|
23
|
+
end
|
24
|
+
break if (cdir = cdir.parent).root?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
18
28
|
def self.class_to_lowercase(class_name = self.class)
|
19
29
|
class_name.to_s.split('::').last.split(/(?=[[:upper:]]|[0-9])/).join('_').downcase.to_s
|
20
30
|
end
|
data/lib/dapp/image/argument.rb
CHANGED
@@ -110,7 +110,7 @@ module Dapp
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def service_options
|
113
|
-
{ entrypoint: project.
|
113
|
+
{ entrypoint: project.bash_bin, name: container_name }
|
114
114
|
end
|
115
115
|
|
116
116
|
def prepared_change
|
@@ -126,7 +126,7 @@ module Dapp
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def prepared_commands
|
129
|
-
return [project.
|
129
|
+
return [project.true_bin] if bash_commands.empty?
|
130
130
|
bash_commands
|
131
131
|
end
|
132
132
|
end
|
data/lib/dapp/image/scratch.rb
CHANGED
@@ -14,10 +14,11 @@ module Dapp
|
|
14
14
|
|
15
15
|
def build!(**_kwargs)
|
16
16
|
build_from_command = if from_archives.empty?
|
17
|
-
"#{project.
|
17
|
+
"#{project.tar_bin} c --files-from /dev/null"
|
18
18
|
else
|
19
|
-
"#{project.
|
19
|
+
"#{project.cat_bin} #{from_archives.join(' ')}"
|
20
20
|
end
|
21
|
+
#FIXME: do not use docker import from system-shellout
|
21
22
|
@built_id = project.system_shellout!("#{build_from_command} | docker import #{prepared_change} - ").stdout.strip
|
22
23
|
end
|
23
24
|
|
data/lib/dapp/project.rb
CHANGED
@@ -51,18 +51,35 @@ module Dapp
|
|
51
51
|
|
52
52
|
def name
|
53
53
|
@name ||= begin
|
54
|
-
if
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
if git_url
|
55
|
+
repo_name = git_url.split('/').last
|
56
|
+
repo_name = repo_name[/.*(?=\.git)/] if repo_name.end_with? '.git'
|
57
|
+
repo_name
|
58
|
+
elsif git_path
|
59
|
+
File.basename(File.dirname(git_path))
|
60
60
|
else
|
61
61
|
File.basename(path)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
def git_url
|
67
|
+
return unless git_config
|
68
|
+
(git_config['remote "origin"'] || {})['url']
|
69
|
+
end
|
70
|
+
|
71
|
+
def git_config
|
72
|
+
@git_config ||= begin
|
73
|
+
IniFile.load(File.join(git_path, 'config')) if git_path
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def git_path
|
78
|
+
defined?(@git_path) ? @git_path : begin
|
79
|
+
@git_path = search_file_upward('.git')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
66
83
|
def path
|
67
84
|
@path ||= expand_path(dappfile_path)
|
68
85
|
end
|
@@ -12,20 +12,10 @@ module Dapp
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def dappfile_path
|
15
|
-
raise Error::Project, code: :dappfile_not_found unless (dappfile_path =
|
15
|
+
raise Error::Project, code: :dappfile_not_found unless (dappfile_path = search_file_upward('Dappfile'))
|
16
16
|
dappfile_path
|
17
17
|
end
|
18
18
|
|
19
|
-
def search_up(file)
|
20
|
-
cdir = Pathname(work_dir)
|
21
|
-
loop do
|
22
|
-
if (path = cdir.join(file)).exist?
|
23
|
-
return path.to_s
|
24
|
-
end
|
25
|
-
break if (cdir = cdir.parent).root?
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
19
|
def work_dir
|
30
20
|
File.expand_path(cli_options[:dir] || Dir.pwd)
|
31
21
|
end
|
@@ -14,7 +14,7 @@ module Dapp
|
|
14
14
|
def base_container
|
15
15
|
@base_container ||= begin
|
16
16
|
if shellout("docker inspect #{base_container_name}").exitstatus.nonzero?
|
17
|
-
log_secondary_process(t(code: 'process.
|
17
|
+
log_secondary_process(t(code: 'process.base_container_creating'), short: true) do
|
18
18
|
shellout!(
|
19
19
|
['docker create',
|
20
20
|
"--name #{base_container_name}",
|
@@ -26,17 +26,17 @@ module Dapp
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
%w(rsync diff date
|
29
|
+
%w(rsync diff date cat
|
30
30
|
stat sleep mkdir find
|
31
31
|
install sed cp true
|
32
32
|
bash tar sudo).each do |cmd|
|
33
|
-
define_method("#{cmd}
|
33
|
+
define_method("#{cmd}_bin") { "/.dapp/deps/base/#{BASE_VERSION}/bin/#{cmd}" }
|
34
34
|
end
|
35
35
|
|
36
36
|
def sudo_command(owner: nil, group: nil)
|
37
37
|
sudo = ''
|
38
38
|
if owner || group
|
39
|
-
sudo = "#{
|
39
|
+
sudo = "#{sudo_bin} -E "
|
40
40
|
sudo += "-u #{sudo_format_user(owner)} " if owner
|
41
41
|
sudo += "-g #{sudo_format_user(group)} " if group
|
42
42
|
end
|
@@ -14,7 +14,7 @@ module Dapp
|
|
14
14
|
def gitartifact_container
|
15
15
|
@gitartifact_container ||= begin
|
16
16
|
if shellout("docker inspect #{gitartifact_container_name}").exitstatus.nonzero?
|
17
|
-
log_secondary_process(t(code: 'process.
|
17
|
+
log_secondary_process(t(code: 'process.gitartifact_container_creating'), short: true) do
|
18
18
|
shellout!(
|
19
19
|
['docker create',
|
20
20
|
"--name #{gitartifact_container_name}",
|
@@ -27,7 +27,7 @@ module Dapp
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def git_bin
|
31
31
|
"/.dapp/deps/gitartifact/#{GITARTIFACT_VERSION}/bin/git"
|
32
32
|
end
|
33
33
|
end # Gitartifact
|
@@ -2,63 +2,15 @@ module Dapp
|
|
2
2
|
# Project
|
3
3
|
class Project
|
4
4
|
module SystemShellout
|
5
|
-
SYSTEM_SHELLOUT_IMAGE = 'ubuntu:
|
6
|
-
SYSTEM_SHELLOUT_VERSION = 3
|
7
|
-
|
8
|
-
def system_shellout_container_name
|
9
|
-
"dapp_system_shellout_#{hashsum [SYSTEM_SHELLOUT_VERSION,
|
10
|
-
SYSTEM_SHELLOUT_IMAGE,
|
11
|
-
Deps::Base::BASE_VERSION,
|
12
|
-
Deps::Gitartifact::GITARTIFACT_VERSION]}"
|
13
|
-
end
|
14
|
-
|
15
|
-
def system_shellout_container
|
16
|
-
do_livecheck = false
|
17
|
-
|
18
|
-
@system_shellout_container ||= begin
|
19
|
-
lock(system_shellout_container_name) do
|
20
|
-
cmd = shellout("docker inspect -f {{.State.Running}} #{system_shellout_container_name}")
|
21
|
-
if cmd.exitstatus.nonzero?
|
22
|
-
start_container = true
|
23
|
-
elsif cmd.stdout.strip == 'false'
|
24
|
-
shellout!("docker rm -f #{system_shellout_container_name}")
|
25
|
-
start_container = true
|
26
|
-
else
|
27
|
-
start_container = false
|
28
|
-
end
|
29
|
-
|
30
|
-
if start_container
|
31
|
-
volumes_from = [base_container, gitartifact_container]
|
32
|
-
log_secondary_process(t(code: 'process.system_shellout_container_loading'), short: true) do
|
33
|
-
shellout! ['docker run --detach --privileged',
|
34
|
-
"--name #{system_shellout_container_name}",
|
35
|
-
*volumes_from.map { |container| "--volumes-from #{container}" },
|
36
|
-
'--volume /:/.system_shellout_root',
|
37
|
-
"#{SYSTEM_SHELLOUT_IMAGE} #{bash_path} -ec 'while true ; do sleep 1 ; done'"].join(' ')
|
38
|
-
|
39
|
-
shellout! ["docker exec #{system_shellout_container_name}",
|
40
|
-
"bash -ec '#{[
|
41
|
-
'mkdir -p /.system_shellout_root/.dapp',
|
42
|
-
'mount --rbind /.dapp /.system_shellout_root/.dapp'
|
43
|
-
].join(' && ')}'"].join(' ')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
do_livecheck = true
|
49
|
-
system_shellout_container_name
|
50
|
-
end
|
51
|
-
|
52
|
-
system_shellout_livecheck! if do_livecheck
|
53
|
-
|
54
|
-
@system_shellout_container
|
55
|
-
end
|
5
|
+
SYSTEM_SHELLOUT_IMAGE = 'ubuntu:16.04'.freeze
|
56
6
|
|
57
7
|
def system_shellout(command, raise_error: false, **kwargs)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
8
|
+
system_shellout_extra(volume: (git_path ? File.dirname(git_path) : path)) do
|
9
|
+
if raise_error
|
10
|
+
shellout! _to_system_shellout_command(command), **kwargs
|
11
|
+
else
|
12
|
+
shellout _to_system_shellout_command(command), **kwargs
|
13
|
+
end
|
62
14
|
end
|
63
15
|
end
|
64
16
|
|
@@ -66,26 +18,38 @@ module Dapp
|
|
66
18
|
system_shellout(command, raise_error: true, **kwargs)
|
67
19
|
end
|
68
20
|
|
69
|
-
|
21
|
+
def system_shellout_extra(volume: [], workdir: nil, &blk)
|
22
|
+
old = system_shellout_opts.dup
|
23
|
+
|
24
|
+
system_shellout_opts[:volume] += Array(volume)
|
25
|
+
system_shellout_opts[:workdir] = workdir if workdir
|
26
|
+
|
27
|
+
yield if block_given?
|
28
|
+
ensure
|
29
|
+
@system_shellout_opts = old
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
70
33
|
|
71
|
-
def
|
72
|
-
|
73
|
-
system_shellout! 'true'
|
74
|
-
rescue Error::Shellout
|
75
|
-
$stderr.puts "\033[1m\033[31mSystem shellout container failure, " \
|
76
|
-
'try to remove if error persists: ' \
|
77
|
-
"docker rm -f #{system_shellout_container_name}\033[0m"
|
78
|
-
raise
|
34
|
+
def system_shellout_opts
|
35
|
+
@system_shellout_opts ||= {volume: []}
|
79
36
|
end
|
80
37
|
|
81
38
|
def _to_system_shellout_command(command)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
39
|
+
volumes_from = [base_container, gitartifact_container]
|
40
|
+
|
41
|
+
['docker run',
|
42
|
+
'--rm',
|
43
|
+
"--workdir #{system_shellout_opts[:workdir] || Dir.pwd}",
|
44
|
+
*volumes_from.map { |container| "--volumes-from #{container}" },
|
45
|
+
*Array(system_shellout_opts[:volume]).map { |volume| "--volume #{volume}:#{volume}" },
|
46
|
+
*SystemShellout.default_env_keys.map { |env_key|
|
47
|
+
env_key = env_key.to_s.upcase
|
48
|
+
"--env #{env_key}=#{ENV[env_key]}"
|
49
|
+
},
|
50
|
+
SYSTEM_SHELLOUT_IMAGE,
|
51
|
+
"#{bash_bin} -ec '#{shellout_pack(command)}'"
|
52
|
+
].join(' ')
|
89
53
|
end
|
90
54
|
|
91
55
|
class << self
|
data/lib/dapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
@@ -124,6 +124,20 @@ dependencies:
|
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: 1.0.1
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: inifile
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 3.0.0
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - "~>"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 3.0.0
|
127
141
|
- !ruby/object:Gem::Dependency
|
128
142
|
name: bundler
|
129
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -431,6 +445,7 @@ files:
|
|
431
445
|
- lib/dapp/dimg/git_artifact.rb
|
432
446
|
- lib/dapp/dimg/path.rb
|
433
447
|
- lib/dapp/dimg/stages.rb
|
448
|
+
- lib/dapp/dimg/system_shellout.rb
|
434
449
|
- lib/dapp/dimg/tags.rb
|
435
450
|
- lib/dapp/docker_registry.rb
|
436
451
|
- lib/dapp/docker_registry/base.rb
|