Buildkit-based output processed a bit differently.

This commit is contained in:
Rumpu-Jussi 2019-11-16 16:38:20 +02:00 committed by Brian Cain
parent 8041d0ae78
commit f3629ebd09
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 15 additions and 6 deletions

View File

@ -18,12 +18,16 @@ module VagrantPlugins
def build(dir, **opts, &block)
args = Array(opts[:extra_args])
args << dir
result = execute('docker', 'build', '-q', *args, &block)
matches = result.scan(/^sha256:([0-9a-f]+)$/i)
result = execute('docker', 'build', '--progress', 'plain', *args, &block)
matches = result.scan(/Successfully built (.+)$/i)
if matches.empty?
# This will cause a stack trace in Vagrant, but it is a bug
# if this happens anyways.
raise "UNKNOWN OUTPUT: #{result}"
# Check for the new output format 'writing image sha256...'
matches = result.scan(/writing image sha256:([0-9a-z]+) done$/i)
if matches.empty?
# This will cause a stack trace in Vagrant, but it is a bug
# if this happens anyways.
raise "UNKNOWN OUTPUT: #{result}"
end
end
# Return the last match, and the capture of it

View File

@ -27,7 +27,12 @@ module VagrantPlugins
stdout: result.stdout
end
result.stdout
# If the new buildkit-based docker build is used, stdout is empty, and the output is in stderr
if result.stdout.to_s.strip.length == 0
result.stderr
else
result.stdout
end
end
def windows?