1
0
Эх сурвалжийг харах

Add support for build labels in 2.1 and 2.2 format
Add cache_from in 2.2 format

Add integration test for build labels

Signed-off-by: Joffrey F <[email protected]>

Joffrey F 8 жил өмнө
parent
commit
49605f2715

+ 2 - 1
compose/config/config_schema_v2.1.json

@@ -58,7 +58,8 @@
               "properties": {
                 "context": {"type": "string"},
                 "dockerfile": {"type": "string"},
-                "args": {"$ref": "#/definitions/list_or_dict"}
+                "args": {"$ref": "#/definitions/list_or_dict"},
+                "labels": {"$ref": "#/definitions/list_or_dict"}
               },
               "additionalProperties": false
             }

+ 3 - 1
compose/config/config_schema_v2.2.json

@@ -58,7 +58,9 @@
               "properties": {
                 "context": {"type": "string"},
                 "dockerfile": {"type": "string"},
-                "args": {"$ref": "#/definitions/list_or_dict"}
+                "args": {"$ref": "#/definitions/list_or_dict"},
+                "labels": {"$ref": "#/definitions/list_or_dict"},
+                "cache_from": {"$ref": "#/definitions/list_of_strings"}
               },
               "additionalProperties": false
             }

+ 15 - 0
tests/integration/service_test.py

@@ -666,6 +666,21 @@ class ServiceTest(DockerClientTestCase):
         assert service.image()
         assert "build_version=2" in service.image()['ContainerConfig']['Cmd']
 
+    def test_build_with_build_labels(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('buildlabels', build={
+            'context': text_type(base_dir),
+            'labels': {'com.docker.compose.test': 'true'}
+        })
+        service.build()
+        assert service.image()
+        assert service.image()['Config']['Labels']['com.docker.compose.test'] == 'true'
+
     def test_start_container_stays_unprivileged(self):
         service = self.create_service('web')
         container = create_and_start_container(service).inspect()