From 9f4827132f1818726be1095f90420255d4c44ba3 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Wed, 24 Nov 2021 19:50:29 +0100 Subject: [PATCH] Add command line option to pass extra build args --- repo2docker/__main__.py | 12 ++++++++++++ repo2docker/app.py | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/repo2docker/__main__.py b/repo2docker/__main__.py index f4f9c8ff..9018f32c 100644 --- a/repo2docker/__main__.py +++ b/repo2docker/__main__.py @@ -212,6 +212,14 @@ def get_argparser(): default=[], ) + argparser.add_argument( + "--build-arg", + dest="build_args", + action="append", + help="Extra build arg to pass to the build process, in form name=value", + default=[], + ) + argparser.add_argument("--subdir", type=str, help=Repo2Docker.subdir.help) argparser.add_argument( @@ -261,6 +269,10 @@ def make_r2d(argv=None): else: r2d.labels[l] = "" + for a in args.build_args: + key, _, val = a.partition("=") + r2d.extra_build_args[key] = val + r2d.repo = args.repo r2d.ref = args.ref diff --git a/repo2docker/app.py b/repo2docker/app.py index cf0576c2..a03fe1df 100755 --- a/repo2docker/app.py +++ b/repo2docker/app.py @@ -248,6 +248,15 @@ class Repo2Docker(Application): config=True, ) + extra_build_args = Dict( + {}, + help=""" + Extra build args to pass to the image build process. + This is pretty much only useful for custom Dockerfile based builds. + """, + config=True, + ) + json_logs = Bool( False, help=""" @@ -777,6 +786,8 @@ class Repo2Docker(Application): } if self.target_repo_dir: build_args["REPO_DIR"] = self.target_repo_dir + build_args.update(self.extra_build_args) + self.log.info( "Using %s builder\n", bp.__class__.__name__,