From a4d9ede97d7336c538a462b9fcc685ad0aa5cfde Mon Sep 17 00:00:00 2001 From: Quentin Guilloteau Date: Wed, 11 Sep 2024 10:51:38 +0200 Subject: [PATCH] add support for --build-arg flag --- artifacts/nickel/europar24/munoz_fault.ncl | 10 +++++++--- ecg/app/ecg.py | 7 ++++--- workflow/nickel/artifact_contract.ncl | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/artifacts/nickel/europar24/munoz_fault.ncl b/artifacts/nickel/europar24/munoz_fault.ncl index ce59696..d3aa336 100644 --- a/artifacts/nickel/europar24/munoz_fault.ncl +++ b/artifacts/nickel/europar24/munoz_fault.ncl @@ -6,10 +6,14 @@ conf_date = 2024, comment = "There are two dockerfiles. a dockerfile from the authors that serves as a base image. we will only rebuild the base image. the top level image appear to be mostly a copy + compile, no install", virtualization = "docker", - buildfile_dir = ".", - dockerfile_path = ".docker/base/dockerfile", + buildfile_dir = "xpn-docker-euro-par2024", + dockerfile_path = "docker/base/dockerfile", + build_args = [ + "UID=1234", + "GID=1000" + ], package_managers = [ "dpkg" ], misc_packages = [ { name = "mpich-4.1.1", url = "https://www.mpich.org/static/downloads/4.1.1/mpich-4.1.1.tar.gz" } ] -} \ No newline at end of file +} diff --git a/ecg/app/ecg.py b/ecg/app/ecg.py index d32169f..70623a1 100755 --- a/ecg/app/ecg.py +++ b/ecg/app/ecg.py @@ -74,9 +74,10 @@ def buildresult_saver(result, buildstatus_path, config_path): timestamp = str(datetime.datetime.timestamp(now)) buildstatus_file.write(f"{artifact_name},{timestamp},{result}\n") -def build_image(path, dockerfile_path, image_name): +def build_image(path, dockerfile_path, image_name, build_args): logging.info(f"Starting building image {image_name}") - build_command = f"docker build --no-cache -t {image_name} -f {dockerfile_path} ." + build_args_str = " ".join(map(lambda x: f"--build-arg {x}", build_args)) + build_command = f"docker build --no-cache -t {image_name} {build_args_str} -f {dockerfile_path} ." build_process = subprocess.run(build_command.split(" "), cwd=path, capture_output=True) build_output = f"stdout:\n{build_process.stdout.decode('utf-8')}\nstderr:\n{build_process.stderr.decode('utf-8')}" logging.info(f"Output of '{build_command}':\n\n{build_output}") @@ -253,7 +254,7 @@ def ecg(artifact_name, config_path, pkglist_path, buildstatus_path, arthashlog_p if artifact_dir != "": path = os.path.join(artifact_dir, config["buildfile_dir"]) - return_code, build_output = build_image(path, config["dockerfile_path"], artifact_name) + return_code, build_output = build_image(path, config["dockerfile_path"], artifact_name, config["build_args"]) if return_code == 0: status = "success" check_env(config, artifact_dir, artifact_name, pkglist_path) diff --git a/workflow/nickel/artifact_contract.ncl b/workflow/nickel/artifact_contract.ncl index 7db8b82..297fa4d 100644 --- a/workflow/nickel/artifact_contract.ncl +++ b/workflow/nickel/artifact_contract.ncl @@ -82,6 +82,11 @@ in | doc "Path to the Dockerfile from the build directory" | FilePath | default = "Dockerfile", + build_args + | doc "Build arguments for Docker ('--build-arg')" + | optional + | Array String + | default = [], package_managers | doc "Package Managers used in the container. Possible values: dpkg, rpm, pacman, pip, conda" | optional