Skip to content

Commit

Permalink
Stream docker compose output while building image
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrictson committed Jun 21, 2024
1 parent fa2b583 commit f4939ee
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/support/docker_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ def stop

def run_compose_command(command, echo=true)
$stderr.puts "[docker compose] #{command}" if echo
stdout, stderr, status = Open3.capture3("docker compose #{command}")

output = stdout + stderr
output.each_line { |line| $stderr.puts "[docker compose] #{line}" } if echo
Open3.popen2e("docker compose #{command}") do |stdin, outerr, wait_thread|
stdin.close
output = Thread.new { capture_stream(outerr, echo) }
[output.value, wait_thread.value]
end
end

[output, status]
def capture_stream(stream, echo=true)
buffer = +''
while line = stream.gets
buffer << line
$stderr.puts("[docker compose] #{line}") if echo
end
buffer
end

def host_verify_options
Expand Down

0 comments on commit f4939ee

Please sign in to comment.