mirror of
https://github.com/docker/compose.git
synced 2025-07-21 20:54:32 +02:00
Merge pull request #6542 from akshitgrover/6028-Add_Quiet_Builds
Add --quiet build flag
This commit is contained in:
commit
40b0ce3e5d
@ -266,6 +266,7 @@ class TopLevelCommand(object):
|
|||||||
-m, --memory MEM Sets memory limit for the build container.
|
-m, --memory MEM Sets memory limit for the build container.
|
||||||
--build-arg key=val Set build-time variables for services.
|
--build-arg key=val Set build-time variables for services.
|
||||||
--parallel Build images in parallel.
|
--parallel Build images in parallel.
|
||||||
|
-q, --quiet Don't print anything to STDOUT
|
||||||
"""
|
"""
|
||||||
service_names = options['SERVICE']
|
service_names = options['SERVICE']
|
||||||
build_args = options.get('--build-arg', None)
|
build_args = options.get('--build-arg', None)
|
||||||
@ -289,6 +290,7 @@ class TopLevelCommand(object):
|
|||||||
build_args=build_args,
|
build_args=build_args,
|
||||||
gzip=options.get('--compress', False),
|
gzip=options.get('--compress', False),
|
||||||
parallel_build=options.get('--parallel', False),
|
parallel_build=options.get('--parallel', False),
|
||||||
|
silent=options.get('--quiet', False)
|
||||||
)
|
)
|
||||||
|
|
||||||
def bundle(self, options):
|
def bundle(self, options):
|
||||||
|
@ -355,18 +355,17 @@ 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):
|
build_args=None, gzip=False, parallel_build=False, rm=True, silent=False):
|
||||||
|
|
||||||
services = []
|
services = []
|
||||||
for service in self.get_services(service_names):
|
for service in self.get_services(service_names):
|
||||||
if service.can_be_built():
|
if service.can_be_built():
|
||||||
services.append(service)
|
services.append(service)
|
||||||
else:
|
elif not silent:
|
||||||
log.info('%s uses an image, skipping' % service.name)
|
log.info('%s uses an image, skipping' % service.name)
|
||||||
|
|
||||||
def build_service(service):
|
def build_service(service):
|
||||||
service.build(no_cache, pull, force_rm, memory, build_args, gzip, rm)
|
service.build(no_cache, pull, force_rm, memory, build_args, gzip, rm, silent)
|
||||||
|
|
||||||
if parallel_build:
|
if parallel_build:
|
||||||
_, errors = parallel.parallel_execute(
|
_, errors = parallel.parallel_execute(
|
||||||
services,
|
services,
|
||||||
|
@ -59,7 +59,6 @@ from .utils import parse_seconds_float
|
|||||||
from .utils import truncate_id
|
from .utils import truncate_id
|
||||||
from .utils import unique_everseen
|
from .utils import unique_everseen
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -1049,7 +1048,10 @@ 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):
|
gzip=False, rm=True, silent=False):
|
||||||
|
output_stream = open(os.devnull, 'w')
|
||||||
|
if not silent:
|
||||||
|
output_stream = sys.stdout
|
||||||
log.info('Building %s' % self.name)
|
log.info('Building %s' % self.name)
|
||||||
|
|
||||||
build_opts = self.options.get('build', {})
|
build_opts = self.options.get('build', {})
|
||||||
@ -1091,7 +1093,7 @@ class Service(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
all_events = list(stream_output(build_output, sys.stdout))
|
all_events = list(stream_output(build_output, output_stream))
|
||||||
except StreamOutputError as e:
|
except StreamOutputError as e:
|
||||||
raise BuildError(self, six.text_type(e))
|
raise BuildError(self, six.text_type(e))
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ _docker_compose_build() {
|
|||||||
|
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
-*)
|
-*)
|
||||||
COMPREPLY=( $( compgen -W "--build-arg --compress --force-rm --help --memory -m --no-cache --no-rm --pull --parallel" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "--build-arg --compress --force-rm --help --memory -m --no-cache --no-rm --pull --parallel -q --quiet" -- "$cur" ) )
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
__docker_compose_complete_services --filter source=build
|
__docker_compose_complete_services --filter source=build
|
||||||
|
@ -113,6 +113,7 @@ __docker-compose_subcommand() {
|
|||||||
$opts_help \
|
$opts_help \
|
||||||
"*--build-arg=[Set build-time variables for one service.]:<varname>=<value>: " \
|
"*--build-arg=[Set build-time variables for one service.]:<varname>=<value>: " \
|
||||||
'--force-rm[Always remove intermediate containers.]' \
|
'--force-rm[Always remove intermediate containers.]' \
|
||||||
|
'(--quiet -q)'{--quiet,-q}'[Curb build output]' \
|
||||||
'(--memory -m)'{--memory,-m}'[Memory limit for the build container.]' \
|
'(--memory -m)'{--memory,-m}'[Memory limit for the build container.]' \
|
||||||
'--no-cache[Do not use cache when building the image.]' \
|
'--no-cache[Do not use cache when building the image.]' \
|
||||||
'--pull[Always attempt to pull a newer version of the image.]' \
|
'--pull[Always attempt to pull a newer version of the image.]' \
|
||||||
|
@ -170,6 +170,13 @@ class CLITestCase(DockerClientTestCase):
|
|||||||
# Prevent tearDown from trying to create a project
|
# Prevent tearDown from trying to create a project
|
||||||
self.base_dir = None
|
self.base_dir = None
|
||||||
|
|
||||||
|
def test_quiet_build(self):
|
||||||
|
self.base_dir = 'tests/fixtures/build-args'
|
||||||
|
result = self.dispatch(['build'], None)
|
||||||
|
quietResult = self.dispatch(['build', '-q'], None)
|
||||||
|
assert result.stdout != ""
|
||||||
|
assert quietResult.stdout == ""
|
||||||
|
|
||||||
def test_help_nonexistent(self):
|
def test_help_nonexistent(self):
|
||||||
self.base_dir = 'tests/fixtures/no-composefile'
|
self.base_dir = 'tests/fixtures/no-composefile'
|
||||||
result = self.dispatch(['help', 'foobar'], returncode=1)
|
result = self.dispatch(['help', 'foobar'], returncode=1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user