class Devkitkat::Service::Driver::Docker

Public Instance Methods

cleanup() click to toggle source
# File lib/devkitkat/service/driver/docker.rb, line 24
def cleanup
  container.stop
end
execute(script_file) click to toggle source
# File lib/devkitkat/service/driver/docker.rb, line 14
def execute(script_file)
  new_path = rewrite_root_path!(script_file)

  if command.interactive?
    container.interactive_shell(new_path)
  else
    container.exec([new_path])
  end
end
prepare() click to toggle source
# File lib/devkitkat/service/driver/docker.rb, line 9
def prepare
  image.pull
  container.start
end

Private Instance Methods

container() click to toggle source
# File lib/devkitkat/service/driver/docker.rb, line 39
def container
  @container ||= Container.new(service)
end
image() click to toggle source
# File lib/devkitkat/service/driver/docker.rb, line 43
def image
  @image ||= Image.new(service)
end
rewrite_root_path!(script_file) click to toggle source
# File lib/devkitkat/service/driver/docker.rb, line 30
def rewrite_root_path!(script_file)
  content = File.read(script_file)
  new_content = content.gsub(command.kit_root, Container::ROOT_IN_CONTAINER)
  File.write(script_file, new_content)

  relative_path = script_file.delete_prefix(command.kit_root)
  File.join(Container::ROOT_IN_CONTAINER, relative_path)
end