Skip to content

Commit 31ec803

Browse files
authored
feat: add --load to docker build (#148)
supports alternative BuildKit drivers Signed-off-by: Tom Plant <[email protected]>
1 parent 891852e commit 31ec803

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

ctfcli/core/image.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def __init__(self, name: str, build_path: Optional[Union[str, PathLike]] = None)
2424
self.built = False
2525

2626
def build(self) -> Optional[str]:
27-
docker_build = subprocess.call(["docker", "build", "-t", self.name, "."], cwd=self.build_path.absolute())
27+
docker_build = subprocess.call(
28+
["docker", "build", "--load", "-t", self.name, "."], cwd=self.build_path.absolute()
29+
)
2830
if docker_build != 0:
2931
return
3032

tests/core/test_image.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def test_build(self, mock_call: MagicMock):
5656

5757
self.assertTrue(image.built)
5858
self.assertEqual(image_name, "test-challenge")
59-
mock_call.assert_called_once_with(["docker", "build", "-t", "test-challenge", "."], cwd=build_path.absolute())
59+
mock_call.assert_called_once_with(
60+
["docker", "build", "--load", "-t", "test-challenge", "."], cwd=build_path.absolute()
61+
)
6062

6163
@mock.patch("ctfcli.core.image.subprocess.call", return_value=1)
6264
def test_build_returns_none_if_failed(self, mock_call: MagicMock):
@@ -68,7 +70,9 @@ def test_build_returns_none_if_failed(self, mock_call: MagicMock):
6870

6971
self.assertFalse(image.built)
7072
self.assertIsNone(image_name)
71-
mock_call.assert_called_once_with(["docker", "build", "-t", "test-challenge", "."], cwd=build_path.absolute())
73+
mock_call.assert_called_once_with(
74+
["docker", "build", "--load", "-t", "test-challenge", "."], cwd=build_path.absolute()
75+
)
7276

7377
@mock.patch("ctfcli.core.image.subprocess.call", return_value=0)
7478
def test_push_built_image(self, mock_call: MagicMock):
@@ -150,7 +154,7 @@ def test_builds_image_before_push(self, mock_call: MagicMock):
150154
mock_call.assert_has_calls(
151155
[
152156
call(
153-
["docker", "build", "-t", "test-challenge", "."],
157+
["docker", "build", "--load", "-t", "test-challenge", "."],
154158
cwd=build_path.absolute(),
155159
),
156160
call(
@@ -224,7 +228,7 @@ def test_builds_image_before_export(self, mock_call: MagicMock):
224228
mock_call.assert_has_calls(
225229
[
226230
call(
227-
["docker", "build", "-t", "test-challenge", "."],
231+
["docker", "build", "--load", "-t", "test-challenge", "."],
228232
cwd=build_path.absolute(),
229233
),
230234
call(

0 commit comments

Comments
 (0)