mirror of
https://github.com/docker/compose.git
synced 2025-07-25 22:54:54 +02:00
Add "fig build" command
This commit is contained in:
parent
853d8ad280
commit
a39db86651
@ -71,6 +71,7 @@ class TopLevelCommand(Command):
|
|||||||
--version Print version and exit
|
--version Print version and exit
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
build Build or rebuild services
|
||||||
kill Kill containers
|
kill Kill containers
|
||||||
logs View output from containers
|
logs View output from containers
|
||||||
ps List containers
|
ps List containers
|
||||||
@ -86,6 +87,14 @@ class TopLevelCommand(Command):
|
|||||||
options['version'] = "fig %s" % __version__
|
options['version'] = "fig %s" % __version__
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
def build(self, options):
|
||||||
|
"""
|
||||||
|
Build or rebuild services.
|
||||||
|
|
||||||
|
Usage: build [SERVICE...]
|
||||||
|
"""
|
||||||
|
self.project.build(service_names=options['SERVICE'])
|
||||||
|
|
||||||
def kill(self, options):
|
def kill(self, options):
|
||||||
"""
|
"""
|
||||||
Kill containers.
|
Kill containers.
|
||||||
|
@ -93,6 +93,13 @@ class Project(object):
|
|||||||
for service in self.get_services(service_names):
|
for service in self.get_services(service_names):
|
||||||
service.kill(**options)
|
service.kill(**options)
|
||||||
|
|
||||||
|
def build(self, service_names=None, **options):
|
||||||
|
for service in self.get_services(service_names):
|
||||||
|
if service.can_be_built():
|
||||||
|
service.build(**options)
|
||||||
|
else:
|
||||||
|
log.info('%s uses an image, skipping')
|
||||||
|
|
||||||
def remove_stopped(self, service_names=None, **options):
|
def remove_stopped(self, service_names=None, **options):
|
||||||
for service in self.get_services(service_names):
|
for service in self.get_services(service_names):
|
||||||
service.remove_stopped(**options)
|
service.remove_stopped(**options)
|
||||||
|
@ -137,7 +137,7 @@ class Service(object):
|
|||||||
if 'volumes' in container_options:
|
if 'volumes' in container_options:
|
||||||
container_options['volumes'] = dict((v.split(':')[1], {}) for v in container_options['volumes'])
|
container_options['volumes'] = dict((v.split(':')[1], {}) for v in container_options['volumes'])
|
||||||
|
|
||||||
if 'build' in self.options:
|
if self.can_be_built():
|
||||||
if len(self.client.images(name=self._build_tag_name())) == 0:
|
if len(self.client.images(name=self._build_tag_name())) == 0:
|
||||||
self.build()
|
self.build()
|
||||||
container_options['image'] = self._build_tag_name()
|
container_options['image'] = self._build_tag_name()
|
||||||
@ -167,6 +167,9 @@ class Service(object):
|
|||||||
|
|
||||||
return image_id
|
return image_id
|
||||||
|
|
||||||
|
def can_be_built(self):
|
||||||
|
return 'build' in self.options
|
||||||
|
|
||||||
def _build_tag_name(self):
|
def _build_tag_name(self):
|
||||||
"""
|
"""
|
||||||
The tag to give to images built for this service.
|
The tag to give to images built for this service.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user