Class: Bauble::Cli::DockerCommandBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/bauble/cli/docker_command_builder.rb

Overview

Builds a docker command

Instance Method Summary collapse

Constructor Details

#initializeDockerCommandBuilder

Returns a new instance of DockerCommandBuilder.



7
8
9
# File 'lib/bauble/cli/docker_command_builder.rb', line 7

def initialize
  @command = 'docker run '
end

Instance Method Details

#buildObject



51
52
53
# File 'lib/bauble/cli/docker_command_builder.rb', line 51

def build
  @command.strip
end

#with_command(cmd) ⇒ Object



41
42
43
44
# File 'lib/bauble/cli/docker_command_builder.rb', line 41

def with_command(cmd)
  @command += %(-c "#{cmd.gsub('"', '\"')}" )
  self
end

#with_entrypoint(entrypoint) ⇒ Object



26
27
28
29
# File 'lib/bauble/cli/docker_command_builder.rb', line 26

def with_entrypoint(entrypoint)
  @command += "--entrypoint #{entrypoint} "
  self
end

#with_env(key, value) ⇒ Object



46
47
48
49
# File 'lib/bauble/cli/docker_command_builder.rb', line 46

def with_env(key, value)
  @command += "-e #{key}=#{value} "
  self
end

#with_image(image) ⇒ Object



36
37
38
39
# File 'lib/bauble/cli/docker_command_builder.rb', line 36

def with_image(image)
  @command += "#{image} "
  self
end

#with_platform(platform) ⇒ Object



31
32
33
34
# File 'lib/bauble/cli/docker_command_builder.rb', line 31

def with_platform(platform)
  @command += "--platform #{platform} "
  self
end

#with_rmObject



11
12
13
14
# File 'lib/bauble/cli/docker_command_builder.rb', line 11

def with_rm
  @command += '--rm '
  self
end

#with_volume(volume) ⇒ Object



16
17
18
19
# File 'lib/bauble/cli/docker_command_builder.rb', line 16

def with_volume(volume)
  @command += "-v #{volume} "
  self
end

#with_workdir(workdir) ⇒ Object



21
22
23
24
# File 'lib/bauble/cli/docker_command_builder.rb', line 21

def with_workdir(workdir)
  @command += "-w #{workdir} "
  self
end