Skip to content

Commit

Permalink
WIP: Build with buildx backend
Browse files Browse the repository at this point in the history
  • Loading branch information
apyrgio committed Feb 6, 2025
1 parent 1cf44b0 commit 75f240e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 16 additions & 1 deletion dev_scripts/reproduce-image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
)
Expand All @@ -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,
Expand Down Expand Up @@ -234,6 +248,7 @@ def main():
args.platform,
args.runtime,
args.debian_archive_date,
args.buildx,
)

logger.info(
Expand Down
10 changes: 9 additions & 1 deletion install/common/build-image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = []
Expand All @@ -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",
Expand Down

0 comments on commit 75f240e

Please sign in to comment.