dapp 0.7.7 → 0.7.8
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 +1 -1
- data/config/en/net_status.yml +4 -0
- data/lib/dapp.rb +1 -1
- data/lib/dapp/builder/chef.rb +63 -19
- data/lib/dapp/cli/base.rb +1 -1
- data/lib/dapp/config/dimg/instance_methods.rb +4 -1
- data/lib/dapp/config/dimg_group.rb +4 -0
- data/lib/dapp/config/dimg_group_base.rb +14 -2
- data/lib/dapp/config/dimg_group_main.rb +4 -4
- data/lib/dapp/dimg/path.rb +1 -1
- data/lib/dapp/project.rb +1 -1
- data/lib/dapp/project/ssh_agent.rb +1 -1
- data/lib/dapp/project/system_shellout.rb +98 -0
- data/lib/dapp/version.rb +1 -1
- metadata +3 -3
- data/lib/dapp/project/shellout/system.rb +0 -101
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 709b971c2b888a73d2837821872216f036e2fa99
|
4
|
+
data.tar.gz: a18c53002d974242830a9b76450a56ba1f6c21f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b142d811cc38199046e90babe262c8f32b7a5dcccd543d0e5c4e41ff5041ef87543a6310f4fef15c19250ac7ba4c1a8c88e4160dcb58c3cc1a09bf91970e6a88
|
7
|
+
data.tar.gz: 580f2b3b2ec5fc28a2042ea635a7b325bfc035f4940477fa3d3e5224b985208252f55326ac6117b174b7a3dd79aeec37c1779240f7e7e3b624d0f44bd7a99a51
|
data/bin/dapp
CHANGED
@@ -15,7 +15,7 @@ begin
|
|
15
15
|
::File.open(filename, 'w') do |dapp_stacktrace|
|
16
16
|
dapp_stacktrace.write "#{e.backtrace.join("\n")}\n"
|
17
17
|
end
|
18
|
-
$stderr.puts "\033[1m\033[
|
18
|
+
$stderr.puts "\033[1m\033[90mStacktrace dumped to #{filename}\033[0m"
|
19
19
|
end
|
20
20
|
|
21
21
|
raise
|
data/config/en/net_status.yml
CHANGED
@@ -52,6 +52,10 @@ en:
|
|
52
52
|
chef:
|
53
53
|
stage_path_overlap: "Cannot install '%{cookbook}' cookbook's path %{from} into %{to}: already exists"
|
54
54
|
mdapp_dependency_in_metadata_forbidden: "Using mdapp as dependency in metadata.rb forbidden: detected '%{dependency}'"
|
55
|
+
cookbook_path_not_found: "Dapp cookbook directory not found at %{path}"
|
56
|
+
cookbook_berksfile_not_found: "Dapp cookbook Berksfile not found at %{path}"
|
57
|
+
cookbook_metadata_not_found: "Dapp cookbook metadata.rb file not found at %{path}"
|
58
|
+
cookbook_not_specified_in_berksfile: "Dapp cookbook '%{name}' not specified in Berksfile at %{path}"
|
55
59
|
registry:
|
56
60
|
incorrect_repo: 'Incorrect repository!'
|
57
61
|
no_such_dimg: 'No such dimg in registry!'
|
data/lib/dapp.rb
CHANGED
@@ -146,7 +146,7 @@ require 'dapp/project/deps/base'
|
|
146
146
|
require 'dapp/project/deps/gitartifact'
|
147
147
|
require 'dapp/project/shellout/streaming'
|
148
148
|
require 'dapp/project/shellout/base'
|
149
|
-
require 'dapp/project/
|
149
|
+
require 'dapp/project/system_shellout'
|
150
150
|
require 'dapp/project'
|
151
151
|
require 'dapp/docker_registry'
|
152
152
|
require 'dapp/docker_registry/mod/request'
|
data/lib/dapp/builder/chef.rb
CHANGED
@@ -79,27 +79,61 @@ module Dapp
|
|
79
79
|
cookbook_metadata.name
|
80
80
|
end
|
81
81
|
|
82
|
+
def cookbook_path(*path)
|
83
|
+
dimg.cookbook_path.tap do |cookbook_path|
|
84
|
+
unless cookbook_path.exist?
|
85
|
+
raise Error, code: :cookbook_path_not_found,
|
86
|
+
data: { path: cookbook_path }
|
87
|
+
end
|
88
|
+
end.join(*path)
|
89
|
+
end
|
90
|
+
|
82
91
|
def berksfile_path
|
83
|
-
|
92
|
+
cookbook_path('Berksfile')
|
84
93
|
end
|
85
94
|
|
86
95
|
def berksfile_lock_path
|
87
|
-
|
96
|
+
cookbook_path('Berksfile.lock')
|
88
97
|
end
|
89
98
|
|
90
99
|
def berksfile
|
91
|
-
@berksfile ||=
|
100
|
+
@berksfile ||= begin
|
101
|
+
unless berksfile_path.exist?
|
102
|
+
raise Error, code: :cookbook_berksfile_not_found,
|
103
|
+
data: { path: berksfile_path.to_s }
|
104
|
+
end
|
105
|
+
|
106
|
+
Berksfile.new(cookbook_path, berksfile_path).tap do |berksfile|
|
107
|
+
unless berksfile.local_cookbook? project_name
|
108
|
+
raise Error, code: :cookbook_not_specified_in_berksfile,
|
109
|
+
data: { name: project_name, path: berksfile_path.to_s }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
92
113
|
end
|
93
114
|
|
94
115
|
def cookbook_metadata_path
|
95
|
-
|
116
|
+
cookbook_path('metadata.rb')
|
117
|
+
end
|
118
|
+
|
119
|
+
def check_cookbook_metadata_path_exist!
|
120
|
+
unless cookbook_metadata_path.exist?
|
121
|
+
raise Error, code: :cookbook_metadata_not_found,
|
122
|
+
data: { path: cookbook_metadata_path }
|
123
|
+
end
|
96
124
|
end
|
97
125
|
|
98
126
|
def cookbook_metadata
|
99
|
-
@cookbook_metadata ||=
|
100
|
-
|
101
|
-
|
102
|
-
|
127
|
+
@cookbook_metadata ||= begin
|
128
|
+
check_cookbook_metadata_path_exist!
|
129
|
+
|
130
|
+
CookbookMetadata.new(cookbook_metadata_path).tap do |metadata|
|
131
|
+
metadata.depends.each do |dependency|
|
132
|
+
if dependency.start_with? 'mdapp-'
|
133
|
+
raise Error, code: :mdapp_dependency_in_metadata_forbidden,
|
134
|
+
data: { dependency: dependency }
|
135
|
+
end
|
136
|
+
end
|
103
137
|
end
|
104
138
|
end
|
105
139
|
end
|
@@ -187,8 +221,17 @@ module Dapp
|
|
187
221
|
end
|
188
222
|
end
|
189
223
|
|
224
|
+
def _update_berksfile_lock_cmd
|
225
|
+
vendor_tmp = SecureRandom.uuid
|
226
|
+
|
227
|
+
["berks vendor -b #{berksfile_path} /tmp/#{vendor_tmp}",
|
228
|
+
"rm -rf /tmp/#{vendor_tmp}"].join(' && ')
|
229
|
+
end
|
230
|
+
|
190
231
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
191
232
|
def install_cookbooks(dest_path, chef_cookbooks_stage: false)
|
233
|
+
check_cookbook_metadata_path_exist!
|
234
|
+
|
192
235
|
volumes_from = [dimg.project.base_container, chefdk_container]
|
193
236
|
process_code = [
|
194
237
|
'process',
|
@@ -200,7 +243,7 @@ module Dapp
|
|
200
243
|
unless dimg.project.dev_mode? || chef_cookbooks_stage
|
201
244
|
commands.push(
|
202
245
|
['if [ ! -f Berksfile.lock ] ; then ',
|
203
|
-
|
246
|
+
"echo \"Berksfile.lock not found, to create run '#{_update_berksfile_lock_cmd}'\" 1>&2 ; ",
|
204
247
|
'exit 1 ; ',
|
205
248
|
'fi'].join
|
206
249
|
)
|
@@ -216,9 +259,11 @@ module Dapp
|
|
216
259
|
)
|
217
260
|
elsif !chef_cookbooks_stage
|
218
261
|
commands.push(
|
219
|
-
"export LOCKDIFF=$(#{dimg.project.diff_path} -u1
|
262
|
+
"export LOCKDIFF=$(#{dimg.project.diff_path} -u1 #{berksfile_lock_path} Berksfile.lock)",
|
220
263
|
['if [ "$LOCKDIFF" != "" ] ; then ',
|
221
|
-
"echo -e \"
|
264
|
+
"echo -e \"",
|
265
|
+
"Bad Berksfile.lock, run '#{_update_berksfile_lock_cmd}' ",
|
266
|
+
"or manually apply change:\\n$LOCKDIFF\" 1>&2 ; ",
|
222
267
|
'exit 1 ; ',
|
223
268
|
'fi'].join
|
224
269
|
)
|
@@ -234,7 +279,7 @@ module Dapp
|
|
234
279
|
.values
|
235
280
|
.map {|cookbook|
|
236
281
|
["#{dimg.project.rsync_path} --archive",
|
237
|
-
|
282
|
+
#*cookbook[:chefignore].map {|path| "--exclude #{path}"}, # FIXME
|
238
283
|
"--relative #{cookbook[:path]} /tmp/local_cookbooks",
|
239
284
|
].join(' ')
|
240
285
|
},
|
@@ -254,9 +299,10 @@ module Dapp
|
|
254
299
|
dimg.project.shellout!(
|
255
300
|
['docker run --rm',
|
256
301
|
volumes_from.map { |container| "--volumes-from #{container}" }.join(' '),
|
257
|
-
*berksfile
|
258
|
-
|
259
|
-
|
302
|
+
*berksfile
|
303
|
+
.local_cookbooks
|
304
|
+
.values
|
305
|
+
.map { |desc| "--volume #{desc[:path]}:#{desc[:path]}" },
|
260
306
|
("--volume #{dimg.project.ssh_auth_sock}:/tmp/dapp-ssh-agent" if dimg.project.ssh_auth_sock),
|
261
307
|
"--volume #{dest_path.tap(&:mkpath)}:#{dest_path}",
|
262
308
|
('--env SSH_AUTH_SOCK=/tmp/dapp-ssh-agent' if dimg.project.ssh_auth_sock),
|
@@ -308,8 +354,7 @@ module Dapp
|
|
308
354
|
cookbook_name = File.basename cookbook_path
|
309
355
|
is_project = (cookbook_name == project_name)
|
310
356
|
is_mdapp = cookbook_name.start_with? 'mdapp-'
|
311
|
-
|
312
|
-
mdapp_enabled = is_mdapp && enabled_modules.include?(mdapp_name)
|
357
|
+
mdapp_enabled = is_mdapp && enabled_modules.include?(cookbook_name)
|
313
358
|
|
314
359
|
paths = if is_project
|
315
360
|
common_dapp_paths = select_existing_paths.call(cookbook_path, [
|
@@ -404,8 +449,7 @@ module Dapp
|
|
404
449
|
"#{cookbook}::#{entrypoint}"
|
405
450
|
end
|
406
451
|
|
407
|
-
enabled_modules.map do |
|
408
|
-
cookbook = "mdapp-#{mod}"
|
452
|
+
enabled_modules.map do |cookbook|
|
409
453
|
if does_entry_exist[cookbook, stage]
|
410
454
|
[cookbook, stage]
|
411
455
|
else
|
data/lib/dapp/cli/base.rb
CHANGED
@@ -9,7 +9,7 @@ module Dapp
|
|
9
9
|
|
10
10
|
option :build_dir,
|
11
11
|
long: '--build-dir PATH',
|
12
|
-
description: 'Directory where build cache stored (DIR/.
|
12
|
+
description: 'Directory where build cache stored (DIR/.dapp_build by default)'
|
13
13
|
|
14
14
|
option :log_quiet,
|
15
15
|
short: '-q',
|
@@ -171,6 +171,7 @@ module Dapp
|
|
171
171
|
when Directive::Base, GitArtifact then variable.send(clone_method)
|
172
172
|
when Symbol then variable
|
173
173
|
when Array then variable.dup
|
174
|
+
when TrueClass, FalseClass then variable
|
174
175
|
else
|
175
176
|
raise
|
176
177
|
end
|
@@ -180,7 +181,9 @@ module Dapp
|
|
180
181
|
end
|
181
182
|
|
182
183
|
def passed_directives
|
183
|
-
[:@_chef, :@_shell, :@_docker,
|
184
|
+
[:@_chef, :@_shell, :@_docker,
|
185
|
+
:@_git_artifact, :@_mount,
|
186
|
+
:@_artifact, :@_builder, :@_dev_mode]
|
184
187
|
end
|
185
188
|
end
|
186
189
|
end
|
@@ -40,6 +40,10 @@ module Dapp
|
|
40
40
|
pass_to_default(dimg)
|
41
41
|
end
|
42
42
|
|
43
|
+
def before_dimg_group_eval(dimg_group)
|
44
|
+
pass_to_default(dimg_group)
|
45
|
+
end
|
46
|
+
|
43
47
|
def check_dimg_directive_order(directive)
|
44
48
|
project.log_config_warning(desc: { code: 'wrong_using_base_directive',
|
45
49
|
data: { directive: directive },
|
@@ -24,7 +24,11 @@ module Dapp
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def dimg_group(&blk)
|
27
|
-
Config::DimgGroup.new(project: project
|
27
|
+
Config::DimgGroup.new(project: project).tap do |dimg_group|
|
28
|
+
before_dimg_group_eval(dimg_group)
|
29
|
+
dimg_group.instance_eval(&blk) if block_given?
|
30
|
+
@_dimg_group << dimg_group
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
def _dimg
|
@@ -34,7 +38,15 @@ module Dapp
|
|
34
38
|
protected
|
35
39
|
|
36
40
|
def before_dimg_eval(dimg)
|
37
|
-
dimg
|
41
|
+
pass_to_default(dimg)
|
42
|
+
end
|
43
|
+
|
44
|
+
def before_dimg_group_eval(dimg_group)
|
45
|
+
pass_to_default(dimg_group)
|
46
|
+
end
|
47
|
+
|
48
|
+
def pass_to_default(obj)
|
49
|
+
obj.instance_variable_set(:@_dev_mode, @_dev_mode)
|
38
50
|
end
|
39
51
|
end
|
40
52
|
end
|
@@ -2,12 +2,12 @@ module Dapp
|
|
2
2
|
module Config
|
3
3
|
# DimgGroupMain
|
4
4
|
class DimgGroupMain < DimgGroupBase
|
5
|
-
def dimg(name = nil)
|
6
|
-
with_dimg_validation { super }
|
5
|
+
def dimg(name = nil, &blk)
|
6
|
+
with_dimg_validation { super(name, &blk) }
|
7
7
|
end
|
8
8
|
|
9
|
-
def dimg_group
|
10
|
-
with_dimg_validation { super }
|
9
|
+
def dimg_group(&blk)
|
10
|
+
with_dimg_validation { super(&blk) }
|
11
11
|
end
|
12
12
|
|
13
13
|
protected
|
data/lib/dapp/dimg/path.rb
CHANGED
data/lib/dapp/project.rb
CHANGED
@@ -6,7 +6,7 @@ module Dapp
|
|
6
6
|
class << self
|
7
7
|
def included(_base)
|
8
8
|
::Dapp::Project::Shellout::Base.default_env_keys << 'SSH_AUTH_SOCK'
|
9
|
-
::Dapp::Project::
|
9
|
+
::Dapp::Project::SystemShellout.default_env_keys << 'SSH_AUTH_SOCK'
|
10
10
|
end
|
11
11
|
end # << self
|
12
12
|
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Dapp
|
2
|
+
# Project
|
3
|
+
class Project
|
4
|
+
module SystemShellout
|
5
|
+
SYSTEM_SHELLOUT_IMAGE = 'ubuntu:14.04'.freeze
|
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
|
56
|
+
|
57
|
+
def system_shellout(command, raise_error: false, **kwargs)
|
58
|
+
if raise_error
|
59
|
+
shellout! _to_system_shellout_command(command), **kwargs
|
60
|
+
else
|
61
|
+
shellout _to_system_shellout_command(command), **kwargs
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def system_shellout!(command, **kwargs)
|
66
|
+
system_shellout(command, raise_error: true, **kwargs)
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def system_shellout_livecheck!
|
72
|
+
# This is stupid container "live check" for now
|
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
|
79
|
+
end
|
80
|
+
|
81
|
+
def _to_system_shellout_command(command)
|
82
|
+
cmd = shellout_pack ["cd #{Dir.pwd}", command].join(' && ')
|
83
|
+
"docker exec #{system_shellout_container} chroot /.system_shellout_root #{bash_path} -ec '#{[
|
84
|
+
*SystemShellout.default_env_keys.map do |env_key|
|
85
|
+
env_key = env_key.to_s.upcase
|
86
|
+
"export #{env_key}=#{ENV[env_key]}"
|
87
|
+
end, cmd
|
88
|
+
].join(' && ')}'"
|
89
|
+
end
|
90
|
+
|
91
|
+
class << self
|
92
|
+
def default_env_keys
|
93
|
+
@default_env_keys ||= []
|
94
|
+
end
|
95
|
+
end # << self
|
96
|
+
end # SystemShellout
|
97
|
+
end # Project
|
98
|
+
end # Dapp
|
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.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|
@@ -495,8 +495,8 @@ files:
|
|
495
495
|
- lib/dapp/project/logging/process.rb
|
496
496
|
- lib/dapp/project/shellout/base.rb
|
497
497
|
- lib/dapp/project/shellout/streaming.rb
|
498
|
-
- lib/dapp/project/shellout/system.rb
|
499
498
|
- lib/dapp/project/ssh_agent.rb
|
499
|
+
- lib/dapp/project/system_shellout.rb
|
500
500
|
- lib/dapp/version.rb
|
501
501
|
homepage: https://github.com/flant/dapp
|
502
502
|
licenses:
|
@@ -1,101 +0,0 @@
|
|
1
|
-
module Dapp
|
2
|
-
# Project
|
3
|
-
class Project
|
4
|
-
module Shellout
|
5
|
-
# System
|
6
|
-
module System
|
7
|
-
SYSTEM_SHELLOUT_IMAGE = 'ubuntu:14.04'.freeze
|
8
|
-
SYSTEM_SHELLOUT_VERSION = 3
|
9
|
-
|
10
|
-
def system_shellout_container_name
|
11
|
-
"dapp_system_shellout_#{hashsum [SYSTEM_SHELLOUT_VERSION,
|
12
|
-
SYSTEM_SHELLOUT_IMAGE,
|
13
|
-
Deps::Base::BASE_VERSION,
|
14
|
-
Deps::Gitartifact::GITARTIFACT_VERSION]}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def system_shellout_container
|
18
|
-
do_livecheck = false
|
19
|
-
|
20
|
-
@system_shellout_container ||= begin
|
21
|
-
lock(system_shellout_container_name) do
|
22
|
-
cmd = shellout("docker inspect -f {{.State.Running}} #{system_shellout_container_name}")
|
23
|
-
if cmd.exitstatus.nonzero?
|
24
|
-
start_container = true
|
25
|
-
elsif cmd.stdout.strip == 'false'
|
26
|
-
shellout!("docker rm -f #{system_shellout_container_name}")
|
27
|
-
start_container = true
|
28
|
-
else
|
29
|
-
start_container = false
|
30
|
-
end
|
31
|
-
|
32
|
-
if start_container
|
33
|
-
volumes_from = [base_container, gitartifact_container]
|
34
|
-
log_secondary_process(t(code: 'process.system_shellout_container_loading'), short: true) do
|
35
|
-
shellout! ['docker run --detach --privileged',
|
36
|
-
"--name #{system_shellout_container_name}",
|
37
|
-
*volumes_from.map { |container| "--volumes-from #{container}" },
|
38
|
-
'--volume /:/.system_shellout_root',
|
39
|
-
"#{SYSTEM_SHELLOUT_IMAGE} #{bash_path} -ec 'while true ; do sleep 1 ; done'"].join(' ')
|
40
|
-
|
41
|
-
shellout! ["docker exec #{system_shellout_container_name}",
|
42
|
-
"bash -ec '#{[
|
43
|
-
'mkdir -p /.system_shellout_root/.dapp',
|
44
|
-
'mount --rbind /.dapp /.system_shellout_root/.dapp'
|
45
|
-
].join(' && ')}'"].join(' ')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
do_livecheck = true
|
51
|
-
system_shellout_container_name
|
52
|
-
end
|
53
|
-
|
54
|
-
system_shellout_livecheck! if do_livecheck
|
55
|
-
|
56
|
-
@system_shellout_container
|
57
|
-
end
|
58
|
-
|
59
|
-
def system_shellout(command, raise_error: false, **kwargs)
|
60
|
-
if raise_error
|
61
|
-
shellout! _to_system_shellout_command(command), **kwargs
|
62
|
-
else
|
63
|
-
shellout _to_system_shellout_command(command), **kwargs
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def system_shellout!(command, **kwargs)
|
68
|
-
system_shellout(command, raise_error: true, **kwargs)
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
def system_shellout_livecheck!
|
74
|
-
# This is stupid container "live check" for now
|
75
|
-
system_shellout! 'true'
|
76
|
-
rescue Error::Shellout
|
77
|
-
$stderr.puts "\033[1m\033[31mSystem shellout container failure, " \
|
78
|
-
'try to remove if error persists: ' \
|
79
|
-
"docker rm -f #{system_shellout_container_name}\033[0m"
|
80
|
-
raise
|
81
|
-
end
|
82
|
-
|
83
|
-
def _to_system_shellout_command(command)
|
84
|
-
cmd = shellout_pack ["cd #{Dir.pwd}", command].join(' && ')
|
85
|
-
"docker exec #{system_shellout_container} chroot /.system_shellout_root #{bash_path} -ec '#{[
|
86
|
-
*System.default_env_keys.map do |env_key|
|
87
|
-
env_key = env_key.to_s.upcase
|
88
|
-
"export #{env_key}=#{ENV[env_key]}"
|
89
|
-
end, cmd
|
90
|
-
].join(' && ')}'"
|
91
|
-
end
|
92
|
-
|
93
|
-
class << self
|
94
|
-
def default_env_keys
|
95
|
-
@default_env_keys ||= []
|
96
|
-
end
|
97
|
-
end # << self
|
98
|
-
end # System
|
99
|
-
end
|
100
|
-
end # Project
|
101
|
-
end # Dapp
|