From 75f240e0aedb86b14d2bb9d258e3d36c4bed55a2 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Thu, 6 Feb 2025 16:35:09 +0200 Subject: [PATCH] WIP: Build with buildx backend --- dev_scripts/reproduce-image.py | 17 ++++++++++++++++- install/common/build-image.py | 10 +++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dev_scripts/reproduce-image.py b/dev_scripts/reproduce-image.py index 49152b0..3c80f9f 100755 --- a/dev_scripts/reproduce-image.py +++ b/dev_scripts/reproduce-image.py @@ -140,11 +140,19 @@ def diffoci_diff(runtime, source, local_target, platform=None): ) -def build_image(tag, use_cache=False, platform=None, runtime=None, date=None): +def build_image( + tag, + use_cache=False, + platform=None, + runtime=None, + date=None, + buildx=False +): """Build the Dangerzone container image with a special tag.""" platform_args = [] if not platform else ["--platform", platform] runtime_args = [] if not runtime else ["--runtime", runtime] date_args = [] if not date else ["--debian-archive-date", date] + buildx_args = [] if not buildx else ["--buildx"] run( "python3", "./install/common/build-image.py", @@ -154,6 +162,7 @@ def build_image(tag, use_cache=False, platform=None, runtime=None, date=None): *date_args, *platform_args, *runtime_args, + *buildx_args, "--tag", tag, ) @@ -169,6 +178,11 @@ def parse_args(): prog=sys.argv[0], description="Dev script for verifying container image reproducibility", ) + parser.add_argument( + "--buildx", + action="store_true", + help="Use the buildx platform of Docker or Podman", + ) parser.add_argument( "--platform", default=None, @@ -234,6 +248,7 @@ def main(): args.platform, args.runtime, args.debian_archive_date, + args.buildx, ) logger.info( diff --git a/install/common/build-image.py b/install/common/build-image.py index 7e2c692..87bc4f6 100644 --- a/install/common/build-image.py +++ b/install/common/build-image.py @@ -68,6 +68,11 @@ def main(): action="store_true", help="Do not save the container image as a tarball in share/container.tar.gz", ) + parser.add_argument( + "--buildx", + action="store_true", + help="Use the buildx platform of Docker or Podman", + ) parser.add_argument( "--compress-level", type=int, @@ -110,6 +115,7 @@ def main(): # Build the container image, and tag it with the calculated tag print("Building container image") + buildx_args = ["buildx", "build"] if args.buildx else ["build"] cache_args = [] if args.use_cache else ["--no-cache"] platform_args = [] if not args.platform else ["--platform", args.platform] build_args = [] @@ -119,11 +125,13 @@ def main(): subprocess.run( [ args.runtime, - "build", + *buildx_args, BUILD_CONTEXT, *build_args, *cache_args, *platform_args, + "--provenance", + "false", "-f", "Dockerfile", "--tag",