Class: Wrapbox::Runner::Docker
- Inherits:
-
Object
- Object
- Wrapbox::Runner::Docker
- Defined in:
- lib/wrapbox/runner/docker.rb
Defined Under Namespace
Classes: Cli, ExecutionError
Instance Attribute Summary collapse
-
#container_definition ⇒ Object
readonly
Returns the value of attribute container_definition.
-
#keep_container ⇒ Object
readonly
Returns the value of attribute keep_container.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(options) ⇒ Docker
constructor
A new instance of Docker.
- #run(class_name, method_name, args, container_definition_overrides: {}, environments: []) ⇒ Object
- #run_cmd(cmds, container_definition_overrides: {}, environments: []) ⇒ Object
Constructor Details
#initialize(options) ⇒ Docker
Returns a new instance of Docker.
16 17 18 19 20 |
# File 'lib/wrapbox/runner/docker.rb', line 16 def initialize() @name = [:name] @container_definition = [:container_definition] @keep_container = [:keep_container] end |
Instance Attribute Details
#container_definition ⇒ Object (readonly)
Returns the value of attribute container_definition.
11 12 13 |
# File 'lib/wrapbox/runner/docker.rb', line 11 def container_definition @container_definition end |
#keep_container ⇒ Object (readonly)
Returns the value of attribute keep_container.
11 12 13 |
# File 'lib/wrapbox/runner/docker.rb', line 11 def keep_container @keep_container end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/wrapbox/runner/docker.rb', line 11 def name @name end |
Instance Method Details
#run(class_name, method_name, args, container_definition_overrides: {}, environments: []) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/wrapbox/runner/docker.rb', line 22 def run(class_name, method_name, args, container_definition_overrides: {}, environments: []) definition = container_definition .merge(container_definition_overrides) envs = base_environments(class_name, method_name, args) envs.concat(extract_environments(environments)) exec_docker(definition: definition, cmd: ["bundle", "exec", "rake", "wrapbox:run"], environments: envs) end |
#run_cmd(cmds, container_definition_overrides: {}, environments: []) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/wrapbox/runner/docker.rb', line 32 def run_cmd(cmds, container_definition_overrides: {}, environments: []) definition = container_definition .merge(container_definition_overrides) environments = extract_environments(environments) ths = cmds.map do |cmd| Thread.new(cmd) do |c| exec_docker(definition: definition, cmd: c.split(/\s+/), environments: environments) end end ths.each(&:join) end |