diff --git a/tljh_repo2docker/builder.py b/tljh_repo2docker/builder.py
index 7356c36..fbef6d3 100644
--- a/tljh_repo2docker/builder.py
+++ b/tljh_repo2docker/builder.py
@@ -39,6 +39,7 @@ async def post(self):
name = data["name"].lower()
memory = data["memory"]
cpu = data["cpu"]
+ buildargs = data.get("buildargs", None)
username = data.get("username", None)
password = data.get("password", None)
@@ -63,7 +64,17 @@ async def post(self):
f"The name of the environment is restricted to the following characters: {IMAGE_NAME_RE}",
)
- await build_image(repo, ref, name, memory, cpu, username, password)
+ extra_buildargs = []
+ if buildargs:
+ for barg in buildargs.split("\n"):
+ if "=" not in barg:
+ raise web.HTTPError(
+ 400,
+ "Invalid build argument format"
+ )
+ extra_buildargs.append(barg)
+
+ await build_image(repo, ref, name, memory, cpu, username, password, extra_buildargs)
self.set_status(200)
self.finish(json.dumps({"status": "ok"}))
diff --git a/tljh_repo2docker/docker.py b/tljh_repo2docker/docker.py
index 6cbdd38..c934986 100644
--- a/tljh_repo2docker/docker.py
+++ b/tljh_repo2docker/docker.py
@@ -55,7 +55,8 @@ async def list_containers():
async def build_image(
- repo, ref, name="", memory=None, cpu=None, username=None, password=None
+ repo, ref, name="", memory=None, cpu=None, username=None, password=None,
+ extra_buildargs=None
):
"""
Build an image given a repo, ref and limits
@@ -100,6 +101,12 @@ async def build_image(
label
]
+ for barg in extra_buildargs or []:
+ cmd += [
+ "--build-arg",
+ barg
+ ]
+
cmd.append(repo)
config = {
diff --git a/tljh_repo2docker/static/js/images.js b/tljh_repo2docker/static/js/images.js
index e274582..9d0aeb0 100644
--- a/tljh_repo2docker/static/js/images.js
+++ b/tljh_repo2docker/static/js/images.js
@@ -36,6 +36,7 @@ require([
dialog.find(".name-input").val("");
dialog.find(".memory-input").val("");
dialog.find(".cpu-input").val("");
+ dialog.find(".build-args-input").val("");
dialog.find(".username-input").val("");
dialog.find(".password-input").val("");
dialog.modal();
@@ -50,6 +51,7 @@ require([
var name = dialog.find(".name-input").val().trim();
var memory = dialog.find(".memory-input").val().trim();
var cpu = dialog.find(".cpu-input").val().trim();
+ var buildargs = dialog.find(".build-args-input").val().trim();
var username = dialog.find(".username-input").val().trim();
var password = dialog.find(".password-input").val().trim();
var spinner = $("#adding-environment-dialog");
@@ -63,6 +65,7 @@ require([
name: name,
memory: memory,
cpu: cpu,
+ buildargs: buildargs,
username: username,
password: password,
}),
diff --git a/tljh_repo2docker/templates/images.html b/tljh_repo2docker/templates/images.html
index 2d1ffd3..4a74589 100644
--- a/tljh_repo2docker/templates/images.html
+++ b/tljh_repo2docker/templates/images.html
@@ -131,7 +131,16 @@
- ˃ Credentials (optional)
+ > Advanced
+
+
+
+ > Credentials (optional)