Tag built images and use them when starting
A basic measure to get round the fact that adding isn't cached. Once Docker supports cached adds, this is probably redundant.
This commit is contained in:
parent
76b6354173
commit
507940535f
2 changed files with 26 additions and 2 deletions
|
|
@ -139,14 +139,20 @@ class Service(object):
|
|||
container_options['volumes'] = dict((v.split(':')[1], {}) for v in container_options['volumes'])
|
||||
|
||||
if 'build' in self.options:
|
||||
container_options['image'] = self.build()
|
||||
if len(self.client.images(name=self._build_tag_name())) == 0:
|
||||
self.build()
|
||||
container_options['image'] = self._build_tag_name()
|
||||
|
||||
return container_options
|
||||
|
||||
def build(self):
|
||||
log.info('Building %s...' % self.name)
|
||||
|
||||
build_output = self.client.build(self.options['build'], stream=True)
|
||||
build_output = self.client.build(
|
||||
self.options['build'],
|
||||
tag=self._build_tag_name(),
|
||||
stream=True
|
||||
)
|
||||
|
||||
image_id = None
|
||||
|
||||
|
|
@ -162,6 +168,12 @@ class Service(object):
|
|||
|
||||
return image_id
|
||||
|
||||
def _build_tag_name(self):
|
||||
"""
|
||||
The tag to give to images built for this service.
|
||||
"""
|
||||
return '%s_%s' % (self.project, self.name)
|
||||
|
||||
|
||||
NAME_RE = re.compile(r'^([^_]+)_([^_]+)_(run_)?(\d+)$')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue