From 47bbc35b749e48f233f6354bd26de134205f914a Mon Sep 17 00:00:00 2001 From: Mark Steve Samson Date: Tue, 1 Jul 2014 11:08:37 +0800 Subject: [PATCH] Add `--no-cache` option to `fig build` (Closes #152) Signed-off-by: Mark Steve Samson --- fig/cli/main.py | 8 ++++++-- fig/project.py | 4 ++-- fig/service.py | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fig/cli/main.py b/fig/cli/main.py index 11230331..b815f908 100644 --- a/fig/cli/main.py +++ b/fig/cli/main.py @@ -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): """ diff --git a/fig/project.py b/fig/project.py index d8044c7d..9b3493c4 100644 --- a/fig/project.py +++ b/fig/project.py @@ -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) diff --git a/fig/service.py b/fig/service.py index 0d29a47c..0045b873 100644 --- a/fig/service.py +++ b/fig/service.py @@ -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: