# frozen_string_literal: true module Jive class Docker attr_reader :shell def initialize(shell = ::Jive.shell) @shell = shell end def build(path) shell.execute([ "docker", "build", "--network=host", "-t", image_tag_for(path), "." ], env: { "DOCKER_BUILDKIT" => "1" }) end def launch(path) shell.execute([ "docker", "run", "--network=host", '--entrypoint=""', "-it", image_tag_for(path), "/bin/bash -l" ]) end def size(path) shell.execute([ :docker, "image", "inspect", '--format="{{.Size}}"', image_tag_for(path) ]) end private def image_tag_for(path) "#{path.basename.to_s.downcase}:latest" end end end