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,22 +73,26 @@ 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", "-v",
"linux/amd64", f"{input_filename}:/tmp/input_file",
"-v", "-v",
f"{input_filename}:/tmp/input_file", f"{pixel_dir}:/dangerzone",
"-v", container_name,
f"{pixel_dir}:/dangerzone", "/usr/bin/python3",
container_name, "/usr/local/bin/dangerzone.py",
"/usr/bin/python3", "document-to-pixels",
"/usr/local/bin/dangerzone.py", ]
"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,25 +100,24 @@ 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", "-v",
"linux/amd64", f"{pixel_dir}:/dangerzone",
"-v", "-v",
f"{pixel_dir}:/dangerzone", f"{safe_dir}:/safezone",
"-v", "-e",
f"{safe_dir}:/safezone", f"OCR={ocr}",
"-e", "-e",
f"OCR={ocr}", f"OCR_LANGUAGE={ocr_lang}",
"-e", container_name,
f"OCR_LANGUAGE={ocr_lang}", "/usr/bin/python3",
container_name, "/usr/local/bin/dangerzone.py",
"/usr/bin/python3", "pixels-to-pdf",
"/usr/local/bin/dangerzone.py", ]
"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")