Skip to content

Commit 5ed2d6d

Browse files
committed
Build images with buildkit for deterministic hashes
1 parent 3878dc0 commit 5ed2d6d

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/confcom/azext_confcom/tests/latest/test_confcom_containers_from_image.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
# --------------------------------------------------------------------------------------------
55

66
import json
7+
import os
8+
import subprocess
79
import tempfile
8-
import docker
910
import pytest
1011
import portalocker
1112

@@ -23,18 +24,27 @@
2324
SAMPLES_ROOT = CONFCOM_DIR / "samples" / "images"
2425
DOCKER_LOCK = Path(tempfile.gettempdir()) / "confcom-docker.lock"
2526

26-
2727
@pytest.fixture(scope="session", autouse=True)
2828
def build_test_containers():
2929

30-
docker_client = docker.from_env()
30+
env = os.environ.copy()
31+
env["DOCKER_BUILDKIT"] = "1"
32+
3133
with portalocker.Lock(DOCKER_LOCK.as_posix(), timeout=20):
3234
for image_sample in SAMPLES_ROOT.iterdir():
33-
docker_client.images.build(
34-
path=str(image_sample),
35-
tag=f"confcom_test_{image_sample.name}",
36-
quiet=True,
37-
rm=True,
35+
subprocess.run(
36+
[
37+
"docker",
38+
"build",
39+
str(image_sample),
40+
"-t",
41+
f"confcom_test_{image_sample.name}",
42+
"--quiet",
43+
],
44+
env=env,
45+
stdout=subprocess.DEVNULL,
46+
stderr=subprocess.DEVNULL,
47+
check=True,
3848
)
3949

4050
yield
@@ -69,4 +79,4 @@ def test_containers_from_image(sample_directory: str, platform: str):
6979
expected_container_def,
7080
ignore_order=True,
7181
)
72-
assert diff == {}, diff
82+
assert diff == {}, diff

src/confcom/samples/images/working_dir/aci_container.inc.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "confcom_test_working_dir",
44
"layers": [
55
"8b4664979ffe3c5188efbbbb30e31716c03bfe880f15f455be0fc3beb4741de9",
6-
"eff9550216100f194b7f04d12ae70e5511ffd7360eec6b947197176701397e60"
6+
"1c4128b7270b18b052aff3f68a5611873057aa0b9ce3acfbf273494e67c63254"
77
],
88
"mounts": [
99
{

0 commit comments

Comments
 (0)