mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Add platform
This commit is contained in:
parent
c96c0d6eed
commit
3e7b1edc34
2 changed files with 16 additions and 3 deletions
|
@ -114,9 +114,9 @@ def diffoci_download():
|
||||||
DIFFOCI_PATH.chmod(DIFFOCI_PATH.stat().st_mode | stat.S_IEXEC)
|
DIFFOCI_PATH.chmod(DIFFOCI_PATH.stat().st_mode | stat.S_IEXEC)
|
||||||
|
|
||||||
|
|
||||||
def diffoci_diff(source, local_target):
|
def diffoci_diff(runtime, source, local_target):
|
||||||
"""Diff the source image against the recently built target image using diffoci."""
|
"""Diff the source image against the recently built target image using diffoci."""
|
||||||
target = f"podman://{local_target}"
|
target = f"{runtime}://{local_target}"
|
||||||
try:
|
try:
|
||||||
return run(
|
return run(
|
||||||
str(DIFFOCI_PATH),
|
str(DIFFOCI_PATH),
|
||||||
|
@ -150,12 +150,18 @@ def parse_args():
|
||||||
image_tag = git_determine_tag()
|
image_tag = git_determine_tag()
|
||||||
# TODO: Remove the local "podman://" prefix once we have started pushing images to a
|
# TODO: Remove the local "podman://" prefix once we have started pushing images to a
|
||||||
# remote.
|
# remote.
|
||||||
default_image_name = f"podman://{IMAGE_NAME}:{image_tag}"
|
default_image_name = f"{IMAGE_NAME}:{image_tag}"
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
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(
|
||||||
|
"--runtime",
|
||||||
|
choices=["docker", "podman"],
|
||||||
|
default=CONTAINER_RUNTIME,
|
||||||
|
help=f"The container runtime for building the image (default: {CONTAINER_RUNTIME})",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--source",
|
"--source",
|
||||||
default=default_image_name,
|
default=default_image_name,
|
||||||
|
|
|
@ -58,6 +58,11 @@ def main():
|
||||||
default=CONTAINER_RUNTIME,
|
default=CONTAINER_RUNTIME,
|
||||||
help=f"The container runtime for building the image (default: {CONTAINER_RUNTIME})",
|
help=f"The container runtime for building the image (default: {CONTAINER_RUNTIME})",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--platform",
|
||||||
|
default=None,
|
||||||
|
help=f"The platform for building the image (default: current platform)",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--no-save",
|
"--no-save",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
@ -100,12 +105,14 @@ 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")
|
||||||
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]
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
args.runtime,
|
args.runtime,
|
||||||
"build",
|
"build",
|
||||||
BUILD_CONTEXT,
|
BUILD_CONTEXT,
|
||||||
*cache_args,
|
*cache_args,
|
||||||
|
*platform_args,
|
||||||
"-f",
|
"-f",
|
||||||
"Dockerfile",
|
"Dockerfile",
|
||||||
"--tag",
|
"--tag",
|
||||||
|
|
Loading…
Reference in a new issue