Module: Dapp::Project::Shellout::System

Included in:
Dapp::Project
Defined in:
lib/dapp/project/shellout/system.rb

Overview

System

Constant Summary collapse

SYSTEM_SHELLOUT_IMAGE =
'ubuntu:14.04'.freeze
SYSTEM_SHELLOUT_VERSION =
2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_env_keysObject



86
87
88
# File 'lib/dapp/project/shellout/system.rb', line 86

def default_env_keys
  @default_env_keys ||= []
end

Instance Method Details

#system_shellout(command, raise_error: false, **kwargs) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/dapp/project/shellout/system.rb', line 49

def system_shellout(command, raise_error: false, **kwargs)
  if raise_error
    shellout! _to_system_shellout_command(command), **kwargs
  else
    shellout _to_system_shellout_command(command), **kwargs
  end
end

#system_shellout!(command, **kwargs) ⇒ Object



57
58
59
# File 'lib/dapp/project/shellout/system.rb', line 57

def system_shellout!(command, **kwargs)
  system_shellout(command, raise_error: true, **kwargs)
end

#system_shellout_containerObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dapp/project/shellout/system.rb', line 17

def system_shellout_container
  do_livecheck = false

  @system_shellout_container ||= begin
    lock(system_shellout_container_name) do
      if shellout("docker inspect #{system_shellout_container_name}").exitstatus.nonzero?
        volumes_from = [base_container, gitartifact_container]
        log_secondary_process(t(code: 'process.system_shellout_container_loading'), short: true) do
          shellout! ['docker run --detach --privileged', '--restart always',
                     "--name #{system_shellout_container_name}",
                     *volumes_from.map { |container| "--volumes-from #{container}" },
                     '--volume /:/.system_shellout_root',
                     "#{SYSTEM_SHELLOUT_IMAGE} #{bash_path} -ec 'while true ; do sleep 1 ; done'"].join(' ')

          shellout! ["docker exec #{system_shellout_container_name}",
                     "bash -ec '#{[
                       'mkdir -p /.system_shellout_root/.dapp',
                       'mount --rbind /.dapp /.system_shellout_root/.dapp'
                     ].join(' && ')}'"].join(' ')
        end
      end
    end

    do_livecheck = true
    system_shellout_container_name
  end

  system_shellout_livecheck! if do_livecheck

  @system_shellout_container
end

#system_shellout_container_nameObject



10
11
12
13
14
15
# File 'lib/dapp/project/shellout/system.rb', line 10

def system_shellout_container_name
  "dapp_system_shellout_#{hashsum [SYSTEM_SHELLOUT_VERSION,
                                   SYSTEM_SHELLOUT_IMAGE,
                                   Deps::Base::BASE_VERSION,
                                   Deps::Gitartifact::GITARTIFACT_VERSION]}"
end