WIP: Build with buildx backend

This commit is contained in:
Alex Pyrgiotis 2025-02-06 16:35:09 +02:00
parent 1cf44b026c
commit 75f240e0ae
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA
2 changed files with 25 additions and 2 deletions

View file

@ -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.""" """Build the Dangerzone container image with a special tag."""
platform_args = [] if not platform else ["--platform", platform] platform_args = [] if not platform else ["--platform", platform]
runtime_args = [] if not runtime else ["--runtime", runtime] runtime_args = [] if not runtime else ["--runtime", runtime]
date_args = [] if not date else ["--debian-archive-date", date] date_args = [] if not date else ["--debian-archive-date", date]
buildx_args = [] if not buildx else ["--buildx"]
run( run(
"python3", "python3",
"./install/common/build-image.py", "./install/common/build-image.py",
@ -154,6 +162,7 @@ def build_image(tag, use_cache=False, platform=None, runtime=None, date=None):
*date_args, *date_args,
*platform_args, *platform_args,
*runtime_args, *runtime_args,
*buildx_args,
"--tag", "--tag",
tag, tag,
) )
@ -169,6 +178,11 @@ def parse_args():
prog=sys.argv[0], prog=sys.argv[0],
description="Dev script for verifying container image reproducibility", 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( parser.add_argument(
"--platform", "--platform",
default=None, default=None,
@ -234,6 +248,7 @@ def main():
args.platform, args.platform,
args.runtime, args.runtime,
args.debian_archive_date, args.debian_archive_date,
args.buildx,
) )
logger.info( logger.info(

View file

@ -68,6 +68,11 @@ def main():
action="store_true", action="store_true",
help="Do not save the container image as a tarball in share/container.tar.gz", 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( parser.add_argument(
"--compress-level", "--compress-level",
type=int, type=int,
@ -110,6 +115,7 @@ def main():
# Build the container image, and tag it with the calculated tag # Build the container image, and tag it with the calculated tag
print("Building container image") print("Building container image")
buildx_args = ["buildx", "build"] if args.buildx else ["build"]
cache_args = [] if args.use_cache else ["--no-cache"] cache_args = [] if args.use_cache else ["--no-cache"]
platform_args = [] if not args.platform else ["--platform", args.platform] platform_args = [] if not args.platform else ["--platform", args.platform]
build_args = [] build_args = []
@ -119,11 +125,13 @@ def main():
subprocess.run( subprocess.run(
[ [
args.runtime, args.runtime,
"build", *buildx_args,
BUILD_CONTEXT, BUILD_CONTEXT,
*build_args, *build_args,
*cache_args, *cache_args,
*platform_args, *platform_args,
"--provenance",
"false",
"-f", "-f",
"Dockerfile", "Dockerfile",
"--tag", "--tag",