providers/docker: build output [GH-3739]

This commit is contained in:
Mitchell Hashimoto 2014-10-23 15:02:46 -07:00
parent 097886b2ce
commit b656bf4ae5
3 changed files with 14 additions and 5 deletions

View File

@ -10,6 +10,7 @@ IMPROVEMENTS:
- guests/suse: Support NFS client install, rsync setup. [GH-4492] - guests/suse: Support NFS client install, rsync setup. [GH-4492]
- guests/tinycore: Support changing host names. [GH-4469] - guests/tinycore: Support changing host names. [GH-4469]
- guests/windows: Hostname can be set without reboot. [GH-4687] - guests/windows: Hostname can be set without reboot. [GH-4687]
- providers/docker: Build output is now shown. [GH-3739]
- providers/docker: Can now start containers from private repositories - providers/docker: Can now start containers from private repositories
more easily. Vagrant will login for you if you specify auth. [GH-4042] more easily. Vagrant will login for you if you specify auth. [GH-4042]
- providers/docker: `stop_timeout` can be used to modify the `docker stop` - providers/docker: `stop_timeout` can be used to modify the `docker stop`

View File

@ -1,9 +1,13 @@
require "log4r" require "log4r"
require "vagrant/util/ansi_escape_code_remover"
module VagrantPlugins module VagrantPlugins
module DockerProvider module DockerProvider
module Action module Action
class Build class Build
include Vagrant::Util::ANSIEscapeCodeRemover
def initialize(app, env) def initialize(app, env)
@app = app @app = app
@logger = Log4r::Logger.new("vagrant::docker::build") @logger = Log4r::Logger.new("vagrant::docker::build")
@ -37,9 +41,13 @@ module VagrantPlugins
machine.ui.output(I18n.t("docker_provider.building")) machine.ui.output(I18n.t("docker_provider.building"))
image = machine.provider.driver.build( image = machine.provider.driver.build(
build_dir, build_dir,
extra_args: machine.provider_config.build_args, extra_args: machine.provider_config.build_args) do |type, data|
) data = remove_ansi_escape_codes(data.chomp).chomp
machine.ui.detail("Image: #{image}") env[:ui].detail(data) if data != ""
end
# Output the final image
machine.ui.detail("\nImage: #{image}")
# Store the image ID # Store the image ID
image_file.open("w") do |f| image_file.open("w") do |f|

View File

@ -14,10 +14,10 @@ module VagrantPlugins
@executor = Executor::Local.new @executor = Executor::Local.new
end end
def build(dir, **opts) def build(dir, **opts, &block)
args = Array(opts[:extra_args]) args = Array(opts[:extra_args])
args << dir args << dir
result = execute('docker', 'build', *args) result = execute('docker', 'build', *args, &block)
matches = result.scan(/Successfully built (.+)$/i) matches = result.scan(/Successfully built (.+)$/i)
if matches.empty? if matches.empty?
# This will cause a stack trace in Vagrant, but it is a bug # This will cause a stack trace in Vagrant, but it is a bug