Only add --platform linux/amd64 in docker, not in podman

This commit is contained in:
Micah Lee 2021-11-29 16:44:30 -08:00
parent 1d08e12f5e
commit 8757ff8296
No known key found for this signature in database
GPG key ID: 403C2657CD994F73

View file

@ -73,13 +73,16 @@ def convert(input_filename, output_filename, ocr_lang, stdout_callback):
os.makedirs(pixel_dir, exist_ok=True) os.makedirs(pixel_dir, exist_ok=True)
os.makedirs(safe_dir, exist_ok=True) os.makedirs(safe_dir, exist_ok=True)
if container_tech == "docker":
platform_args = ["--platform", "linux/amd64"]
else:
platform_args = []
# Convert document to pixels # Convert document to pixels
args = [ args = (
"run", ["run", "--network", "none"]
"--network", + platform_args
"none", + [
"--platform",
"linux/amd64",
"-v", "-v",
f"{input_filename}:/tmp/input_file", f"{input_filename}:/tmp/input_file",
"-v", "-v",
@ -89,6 +92,7 @@ def convert(input_filename, output_filename, ocr_lang, stdout_callback):
"/usr/local/bin/dangerzone.py", "/usr/local/bin/dangerzone.py",
"document-to-pixels", "document-to-pixels",
] ]
)
ret = exec_container(args, stdout_callback) ret = exec_container(args, stdout_callback)
if ret != 0: if ret != 0:
print("documents-to-pixels failed") print("documents-to-pixels failed")
@ -96,12 +100,10 @@ def convert(input_filename, output_filename, ocr_lang, stdout_callback):
# TODO: validate convert to pixels output # TODO: validate convert to pixels output
# Convert pixels to safe PDF # Convert pixels to safe PDF
args = [ args = (
"run", ["run", "--network", "none"]
"--network", + platform_args
"none", + [
"--platform",
"linux/amd64",
"-v", "-v",
f"{pixel_dir}:/dangerzone", f"{pixel_dir}:/dangerzone",
"-v", "-v",
@ -115,6 +117,7 @@ def convert(input_filename, output_filename, ocr_lang, stdout_callback):
"/usr/local/bin/dangerzone.py", "/usr/local/bin/dangerzone.py",
"pixels-to-pdf", "pixels-to-pdf",
] ]
)
ret = exec_container(args, stdout_callback) ret = exec_container(args, stdout_callback)
if ret != 0: if ret != 0:
print("pixels-to-pdf failed") print("pixels-to-pdf failed")