mirror of
https://github.com/docker/compose.git
synced 2025-07-28 16:14:06 +02:00
feat: add --progress flag
Signed-off-by: Nao YONASHIRO <yonashiro@r.recruit.co.jp>
This commit is contained in:
parent
862a13b8f3
commit
81e223d499
@ -270,6 +270,9 @@ class TopLevelCommand(object):
|
|||||||
--no-cache Do not use cache when building the image.
|
--no-cache Do not use cache when building the image.
|
||||||
--no-rm Do not remove intermediate containers after a successful build.
|
--no-rm Do not remove intermediate containers after a successful build.
|
||||||
--parallel Build images in parallel.
|
--parallel Build images in parallel.
|
||||||
|
--progress string Set type of progress output (auto, plain, tty).
|
||||||
|
EXPERIMENTAL flag for native builder.
|
||||||
|
To enable, run with COMPOSE_NATIVE_BUILDER=1)
|
||||||
--pull Always attempt to pull a newer version of the image.
|
--pull Always attempt to pull a newer version of the image.
|
||||||
-q, --quiet Don't print anything to STDOUT
|
-q, --quiet Don't print anything to STDOUT
|
||||||
"""
|
"""
|
||||||
@ -297,6 +300,7 @@ class TopLevelCommand(object):
|
|||||||
parallel_build=options.get('--parallel', False),
|
parallel_build=options.get('--parallel', False),
|
||||||
silent=options.get('--quiet', False),
|
silent=options.get('--quiet', False),
|
||||||
cli=native_builder,
|
cli=native_builder,
|
||||||
|
progress=options.get('--progress'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def bundle(self, options):
|
def bundle(self, options):
|
||||||
|
@ -355,7 +355,8 @@ class Project(object):
|
|||||||
return containers
|
return containers
|
||||||
|
|
||||||
def build(self, service_names=None, no_cache=False, pull=False, force_rm=False, memory=None,
|
def build(self, service_names=None, no_cache=False, pull=False, force_rm=False, memory=None,
|
||||||
build_args=None, gzip=False, parallel_build=False, rm=True, silent=False, cli=False):
|
build_args=None, gzip=False, parallel_build=False, rm=True, silent=False, cli=False,
|
||||||
|
progress=None):
|
||||||
|
|
||||||
services = []
|
services = []
|
||||||
for service in self.get_services(service_names):
|
for service in self.get_services(service_names):
|
||||||
@ -368,7 +369,7 @@ class Project(object):
|
|||||||
log.warning("Native build is an experimental feature and could change at any time")
|
log.warning("Native build is an experimental feature and could change at any time")
|
||||||
|
|
||||||
def build_service(service):
|
def build_service(service):
|
||||||
service.build(no_cache, pull, force_rm, memory, build_args, gzip, rm, silent, cli)
|
service.build(no_cache, pull, force_rm, memory, build_args, gzip, rm, silent, cli, progress)
|
||||||
if parallel_build:
|
if parallel_build:
|
||||||
_, errors = parallel.parallel_execute(
|
_, errors = parallel.parallel_execute(
|
||||||
services,
|
services,
|
||||||
|
@ -1052,7 +1052,7 @@ class Service(object):
|
|||||||
return [build_spec(secret) for secret in self.secrets]
|
return [build_spec(secret) for secret in self.secrets]
|
||||||
|
|
||||||
def build(self, no_cache=False, pull=False, force_rm=False, memory=None, build_args_override=None,
|
def build(self, no_cache=False, pull=False, force_rm=False, memory=None, build_args_override=None,
|
||||||
gzip=False, rm=True, silent=False, cli=False):
|
gzip=False, rm=True, silent=False, cli=False, progress=None):
|
||||||
output_stream = open(os.devnull, 'w')
|
output_stream = open(os.devnull, 'w')
|
||||||
if not silent:
|
if not silent:
|
||||||
output_stream = sys.stdout
|
output_stream = sys.stdout
|
||||||
@ -1073,8 +1073,8 @@ class Service(object):
|
|||||||
'Impossible to perform platform-targeted builds for API version < 1.35'
|
'Impossible to perform platform-targeted builds for API version < 1.35'
|
||||||
)
|
)
|
||||||
|
|
||||||
build_image = self.client.build if not cli else cli_build
|
builder = self.client if not cli else _CLIBuilder(progress)
|
||||||
build_output = build_image(
|
build_output = builder.build(
|
||||||
path=path,
|
path=path,
|
||||||
tag=self.image_name,
|
tag=self.image_name,
|
||||||
rm=rm,
|
rm=rm,
|
||||||
@ -1707,7 +1707,11 @@ def rewrite_build_path(path):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
def cli_build(path, tag=None, quiet=False, fileobj=None,
|
class _CLIBuilder(object):
|
||||||
|
def __init__(self, progress):
|
||||||
|
self._progress = progress
|
||||||
|
|
||||||
|
def build(self, path, tag=None, quiet=False, fileobj=None,
|
||||||
nocache=False, rm=False, timeout=None,
|
nocache=False, rm=False, timeout=None,
|
||||||
custom_context=False, encoding=None, pull=False,
|
custom_context=False, encoding=None, pull=False,
|
||||||
forcerm=False, dockerfile=None, container_limits=None,
|
forcerm=False, dockerfile=None, container_limits=None,
|
||||||
@ -1779,6 +1783,7 @@ def cli_build(path, tag=None, quiet=False, fileobj=None,
|
|||||||
command_builder.add_flag("--force-rm", forcerm)
|
command_builder.add_flag("--force-rm", forcerm)
|
||||||
command_builder.add_arg("--memory", container_limits.get("memory"))
|
command_builder.add_arg("--memory", container_limits.get("memory"))
|
||||||
command_builder.add_flag("--no-cache", nocache)
|
command_builder.add_flag("--no-cache", nocache)
|
||||||
|
command_builder.add_flag("--progress", self._progress)
|
||||||
command_builder.add_flag("--pull", pull)
|
command_builder.add_flag("--pull", pull)
|
||||||
command_builder.add_arg("--tag", tag)
|
command_builder.add_arg("--tag", tag)
|
||||||
command_builder.add_arg("--target", target)
|
command_builder.add_arg("--target", target)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user