Class: KuberKit::Shell::Commands::DockerComposeCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/shell/commands/docker_compose_commands.rb

Instance Method Summary collapse

Instance Method Details

#run(shell, path, service:, args: nil, command: nil, detached: false, interactive: false) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kuber_kit/shell/commands/docker_compose_commands.rb', line 2

def run(shell, path, service:, args: nil, command: nil, detached: false, interactive: false)
  command_parts = [
    "docker-compose",
    "-f #{path}",
    "run",
  ]
  

  command_parts << "-d" if detached
  command_parts << Array(args).join(" ") if args
  command_parts << service
  command_parts << command if command
  
  if interactive
    shell.interactive!(command_parts.join(" "))
  else
    shell.exec!(command_parts.join(" "), merge_stderr: true)
  end
end