lib/dockly/build_cache/docker.rb in dockly-1.5.14 vs lib/dockly/build_cache/docker.rb in dockly-1.5.15

- old
+ new

@@ -1,8 +1,12 @@ class Dockly::BuildCache::Docker < Dockly::BuildCache::Base attr_accessor :image + def wait_time + 300 # max 5 minutes + end + def execute! ensure_present! :image super image end @@ -28,11 +32,11 @@ path = File.expand_path(cache.path) path_parent = File.dirname(path) tar_flags = keep_old_files ? '-xkf' : 'xf' container = ::Docker::Container.create( 'Image' => image.id, - 'Cmd' => ['/bin/bash', '-lc', [ + 'Cmd' => ['/bin/bash', '-c', [ "mkdir -p #{File.dirname(output_directory)}", '&&', "tar #{tar_flags} #{File.join('/', 'host', path)} -C #{File.dirname(output_directory)}" ].join(' ') ], @@ -83,14 +87,14 @@ body end end def run_command(command) - resp = "" debug "running command `#{command}` on image #{image.id}" - container = image.run(["/bin/bash", "-lc", "cd #{command_directory} && #{command}"]) - container.attach(logs: true) { |source,chunk| resp += chunk } - status = container.wait['StatusCode'] + container = image.run(["/bin/bash", "-c", "cd #{command_directory} && #{command}"]) + debug "command running in container #{container.id}" + status = container.wait(wait_time)['StatusCode'] + resp = container.streaming_logs(stdout: true, stderr: true) debug "`#{command}` returned the following output:" debug resp.strip debug "`#{command}` exited with status #{status}, resulting container id: #{container.id}" [status, resp.strip, container] end