|
@@ -21,6 +21,7 @@ from . import __version__
|
|
|
from . import const
|
|
|
from . import progress_stream
|
|
|
from .config import DOCKER_CONFIG_KEYS
|
|
|
+from .config import merge_build_args
|
|
|
from .config import merge_environment
|
|
|
from .config.types import ServicePort
|
|
|
from .config.types import VolumeSpec
|
|
@@ -803,13 +804,18 @@ class Service(object):
|
|
|
|
|
|
return [build_spec(secret) for secret in self.secrets]
|
|
|
|
|
|
- def build(self, no_cache=False, pull=False, force_rm=False):
|
|
|
+ def build(self, no_cache=False, pull=False, force_rm=False, build_args=None):
|
|
|
log.info('Building %s' % self.name)
|
|
|
|
|
|
build_opts = self.options.get('build', {})
|
|
|
- path = build_opts.get('context')
|
|
|
+
|
|
|
+ self_args_opts = build_opts.get('args', None)
|
|
|
+ if self_args_opts and build_args:
|
|
|
+ merge_build_args(self_args_opts, build_args, self.options.get('environment'))
|
|
|
+
|
|
|
# python2 os.stat() doesn't support unicode on some UNIX, so we
|
|
|
# encode it to a bytestring to be safe
|
|
|
+ path = build_opts.get('context')
|
|
|
if not six.PY3 and not IS_WINDOWS_PLATFORM:
|
|
|
path = path.encode('utf8')
|
|
|
|
|
@@ -822,8 +828,8 @@ class Service(object):
|
|
|
pull=pull,
|
|
|
nocache=no_cache,
|
|
|
dockerfile=build_opts.get('dockerfile', None),
|
|
|
- buildargs=build_opts.get('args', None),
|
|
|
cache_from=build_opts.get('cache_from', None),
|
|
|
+ buildargs=self_args_opts
|
|
|
)
|
|
|
|
|
|
try:
|