Add command line option to pass extra build args
MODIFY
repo2docker/__main__.py
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

MODIFY
repo2docker/app.py
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__,

Add command line option to pass extra build args