Merge pull request #2041 from ggtools/master

Add new --pull option in build.
This commit is contained in:
Aanand Prasad 2015-09-18 16:49:05 +01:00
commit 3e58003bd3
5 changed files with 49 additions and 10 deletions

View file

@ -153,9 +153,11 @@ class TopLevelCommand(Command):
Options:
--no-cache Do not use cache when building the image.
--pull Always attempt to pull a newer version of the image.
"""
no_cache = bool(options.get('--no-cache', False))
project.build(service_names=options['SERVICE'], no_cache=no_cache)
pull = bool(options.get('--pull', False))
project.build(service_names=options['SERVICE'], no_cache=no_cache, pull=pull)
def help(self, project, options):
"""

View file

@ -257,10 +257,10 @@ class Project(object):
for service in self.get_services(service_names):
service.restart(**options)
def build(self, service_names=None, no_cache=False):
def build(self, service_names=None, no_cache=False, pull=False):
for service in self.get_services(service_names):
if service.can_be_built():
service.build(no_cache)
service.build(no_cache, pull)
else:
log.info('%s uses an image, skipping' % service.name)

View file

@ -701,7 +701,7 @@ class Service(object):
ipc_mode=options.get('ipc')
)
def build(self, no_cache=False):
def build(self, no_cache=False, pull=False):
log.info('Building %s' % self.name)
path = self.options['build']
@ -715,7 +715,7 @@ class Service(object):
tag=self.image_name,
stream=True,
rm=True,
pull=False,
pull=pull,
nocache=no_cache,
dockerfile=self.options.get('dockerfile', None),
)