mirror of https://github.com/docker/compose.git
Merge pull request #4514 from jyapayne/cache_from
Add cache_from as an available command
This commit is contained in:
commit
d7df36d4e1
|
@ -71,7 +71,8 @@
|
|||
"properties": {
|
||||
"context": {"type": "string"},
|
||||
"dockerfile": {"type": "string"},
|
||||
"args": {"$ref": "#/definitions/list_or_dict"}
|
||||
"args": {"$ref": "#/definitions/list_or_dict"},
|
||||
"cache_from": {"type": "#/definitions/list_of_strings"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
|
|
|
@ -802,6 +802,7 @@ class Service(object):
|
|||
nocache=no_cache,
|
||||
dockerfile=build_opts.get('dockerfile', None),
|
||||
buildargs=build_opts.get('args', None),
|
||||
cache_from=build_opts.get('cache_from', None),
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
|
@ -32,6 +32,7 @@ from compose.service import NetworkMode
|
|||
from compose.service import Service
|
||||
from tests.integration.testcases import v2_1_only
|
||||
from tests.integration.testcases import v2_only
|
||||
from tests.integration.testcases import v3_only
|
||||
|
||||
|
||||
def create_and_start_container(service, **override_options):
|
||||
|
@ -946,6 +947,20 @@ class ServiceTest(DockerClientTestCase):
|
|||
}.items():
|
||||
self.assertEqual(env[k], v)
|
||||
|
||||
@v3_only()
|
||||
def test_build_with_cachefrom(self):
|
||||
base_dir = tempfile.mkdtemp()
|
||||
self.addCleanup(shutil.rmtree, base_dir)
|
||||
|
||||
with open(os.path.join(base_dir, 'Dockerfile'), 'w') as f:
|
||||
f.write("FROM busybox\n")
|
||||
|
||||
service = self.create_service('cache_from',
|
||||
build={'context': base_dir,
|
||||
'cache_from': ['build1']})
|
||||
service.build()
|
||||
assert service.image()
|
||||
|
||||
@mock.patch.dict(os.environ)
|
||||
def test_resolve_env(self):
|
||||
os.environ['FILE_DEF'] = 'E1'
|
||||
|
|
|
@ -446,6 +446,7 @@ class ServiceTest(unittest.TestCase):
|
|||
nocache=False,
|
||||
rm=True,
|
||||
buildargs=None,
|
||||
cache_from=None,
|
||||
)
|
||||
|
||||
def test_ensure_image_exists_no_build(self):
|
||||
|
@ -482,6 +483,7 @@ class ServiceTest(unittest.TestCase):
|
|||
nocache=False,
|
||||
rm=True,
|
||||
buildargs=None,
|
||||
cache_from=None,
|
||||
)
|
||||
|
||||
def test_build_does_not_pull(self):
|
||||
|
|
Loading…
Reference in New Issue