Add `--no-cache` option to `fig build` (Closes #152)

Signed-off-by: Mark Steve Samson <hello@marksteve.com>
This commit is contained in:
Mark Steve Samson 2014-07-01 11:08:37 +08:00
parent a12f3b40d5
commit 47bbc35b74
3 changed files with 11 additions and 6 deletions

View File

@ -103,9 +103,13 @@ class TopLevelCommand(Command):
e.g. `figtest_db`. If you change a service's `Dockerfile` or the
contents of its build directory, you can run `fig build` to rebuild it.
Usage: build [SERVICE...]
Usage: build [options] [SERVICE...]
Options:
--no-cache Do not use cache when building the image.
"""
self.project.build(service_names=options['SERVICE'])
no_cache = bool(options.get('--no-cache', False))
self.project.build(service_names=options['SERVICE'], no_cache=no_cache)
def help(self, options):
"""

View File

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

View File

@ -356,14 +356,15 @@ class Service(object):
return container_options
def build(self):
def build(self, no_cache=False):
log.info('Building %s...' % self.name)
build_output = self.client.build(
self.options['build'],
tag=self._build_tag_name(),
stream=True,
rm=True
rm=True,
nocache=no_cache,
)
try: