Make --target-repo-dir configurable in binder

Could we make repo2docker's option --target-repo-dir configurable in binderhub?
This would be very helpful for our usecase: we want to commit back to the original repo from the spawned container. When doing this, we dont want to accidental check in config files in the home folder. Thus we would like to check out the repo into a subfolder of the home folder.

If you agree, this would make sense, I would open a PR.

Alternatively:

  • Create a binderhub config option to add additional arguments to repo2docker
  • Make the Build class configurable so one can define and use custom Build classes (like this is already done with FakeBuild)

One thing to check is whether changing target-repo-dir requires a corresponding change in BinderHub to ensure the user is launched in the correct location, or if it “just works”

I just made an experiment.
I patched:

diff --git a/binderhub/build.py b/binderhub/build.py
index 7615fbf..ff91edb 100644
--- a/binderhub/build.py
+++ b/binderhub/build.py
@@ -91,6 +91,7 @@ class Build:
             '--no-clean', '--no-run', '--json-logs',
             '--user-name', 'jovyan',
             '--user-id', '1000',
+            '--target-repo-dir', '/binder_repo',
         ]
         if self.appendix:
             cmd.extend(['--appendix', self.appendix])

Result: binderhub spawns in /binder_repo

1 Like

@manics There is also the working_dir option of KubeSpawner to configure the working dir. Do you think this is enough, or should the behavior be changed?

I’m not sure, though my initial thoughts are that your alternative suggestions of

provide a more extensible way of exposing repo2docker options. I particularly like the idea of making the Build class configurable since it implies knowledge of the BinderHub internals is required, you shouldn’t expect arbitrary r2d arguments to just work.

Since this is getting into the technical details do you want to either open an issue on Issues · jupyterhub/binderhub · GitHub (or if the change is trivial a PR) and cross-reference this discussion?

1 Like

I created a PR: Make build class configurable by g-braeunlich · Pull Request #1319 · jupyterhub/binderhub · GitHub
Not sure about more docs. As you said: it requires knowledge of BinderHub internals, so maybe people should figure this out themselves.

1 Like