Class: Dip::Commands::Compose

Inherits:
Dip::Command show all
Defined in:
lib/dip/commands/compose.rb

Constant Summary collapse

DOCKER_EMBEDDED_DNS =
"127.0.0.11"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Dip::Command

exec_program, exec_subprocess

Constructor Details

#initialize(*argv, shell: true) ⇒ Compose

Returns a new instance of Compose.


15
16
17
18
19
# File 'lib/dip/commands/compose.rb', line 15

def initialize(*argv, shell: true)
  @argv = argv
  @shell = shell
  @config = ::Dip.config.compose || {}
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.


13
14
15
# File 'lib/dip/commands/compose.rb', line 13

def argv
  @argv
end

#configObject (readonly)

Returns the value of attribute config.


13
14
15
# File 'lib/dip/commands/compose.rb', line 13

def config
  @config
end

#shellObject (readonly)

Returns the value of attribute shell.


13
14
15
# File 'lib/dip/commands/compose.rb', line 13

def shell
  @shell
end

Instance Method Details

#executeObject


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dip/commands/compose.rb', line 21

def execute
  Dip.env["DIP_DNS"] ||= find_dns

  compose_argv = Array(find_files) + Array(cli_options) + argv

  if (override_command = compose_command_override)
    override_command, *override_args = override_command.split(" ")
    exec_program(override_command, override_args.concat(compose_argv), shell: shell)
  elsif compose_v2?
    exec_program("docker", compose_argv.unshift("compose"), shell: shell)
  else
    exec_program("docker-compose", compose_argv, shell: shell)
  end
end