providers/docker: build_args [GH-3684]
This commit is contained in:
parent
446dd51af2
commit
030c1ee481
|
@ -4,6 +4,8 @@ IMPROVEMENTS:
|
||||||
|
|
||||||
- command/rdp: Args after "--" are passed directly through to the
|
- command/rdp: Args after "--" are passed directly through to the
|
||||||
RDP client. [GH-3686]
|
RDP client. [GH-3686]
|
||||||
|
- providers/docker: `build_args` config to specify extra args for
|
||||||
|
`docker build`. [GH-3684]
|
||||||
|
|
||||||
## 1.6.1 (May 7, 2014)
|
## 1.6.1 (May 7, 2014)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,10 @@ module VagrantPlugins
|
||||||
if !image || env[:build_rebuild]
|
if !image || env[:build_rebuild]
|
||||||
# Build it
|
# Build it
|
||||||
machine.ui.output(I18n.t("docker_provider.building"))
|
machine.ui.output(I18n.t("docker_provider.building"))
|
||||||
image = machine.provider.driver.build(build_dir)
|
image = machine.provider.driver.build(
|
||||||
|
build_dir,
|
||||||
|
extra_args: machine.provider_config.build_args,
|
||||||
|
)
|
||||||
machine.ui.detail("Image: #{image}")
|
machine.ui.detail("Image: #{image}")
|
||||||
|
|
||||||
# Store the image ID
|
# Store the image ID
|
||||||
|
|
|
@ -5,6 +5,12 @@ module VagrantPlugins
|
||||||
class Config < Vagrant.plugin("2", :config)
|
class Config < Vagrant.plugin("2", :config)
|
||||||
attr_accessor :image, :cmd, :ports, :volumes, :privileged
|
attr_accessor :image, :cmd, :ports, :volumes, :privileged
|
||||||
|
|
||||||
|
# Additional arguments to pass to `docker build` when creating
|
||||||
|
# an image using the build dir setting.
|
||||||
|
#
|
||||||
|
# @return [Array<String>]
|
||||||
|
attr_accessor :build_args
|
||||||
|
|
||||||
# The directory with a Dockerfile to build and use as the basis
|
# The directory with a Dockerfile to build and use as the basis
|
||||||
# for this container. If this is set, "image" should not be set.
|
# for this container. If this is set, "image" should not be set.
|
||||||
#
|
#
|
||||||
|
@ -73,6 +79,7 @@ module VagrantPlugins
|
||||||
attr_accessor :vagrant_vagrantfile
|
attr_accessor :vagrant_vagrantfile
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@build_args = []
|
||||||
@build_dir = UNSET_VALUE
|
@build_dir = UNSET_VALUE
|
||||||
@cmd = UNSET_VALUE
|
@cmd = UNSET_VALUE
|
||||||
@create_args = []
|
@create_args = []
|
||||||
|
@ -126,6 +133,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
|
@build_args = [] if @build_args == UNSET_VALUE
|
||||||
@build_dir = nil if @build_dir == UNSET_VALUE
|
@build_dir = nil if @build_dir == UNSET_VALUE
|
||||||
@cmd = [] if @cmd == UNSET_VALUE
|
@cmd = [] if @cmd == UNSET_VALUE
|
||||||
@create_args = [] if @create_args == UNSET_VALUE
|
@create_args = [] if @create_args == UNSET_VALUE
|
||||||
|
|
|
@ -15,7 +15,9 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def build(dir, **opts)
|
def build(dir, **opts)
|
||||||
result = execute('docker', 'build', dir)
|
args = Array(opts[:extra_args])
|
||||||
|
args << dir
|
||||||
|
result = execute('docker', 'build', *args)
|
||||||
regexp = /Successfully built (.+)$/i
|
regexp = /Successfully built (.+)$/i
|
||||||
match = regexp.match(result)
|
match = regexp.match(result)
|
||||||
if !match
|
if !match
|
||||||
|
|
Loading…
Reference in New Issue