Something people often want is to de-couple the content of a repository from the environment that is needed to run it. This would allow you to update the content of a repo without needing to re-build the Binder needed for it.
One option is to use a tool called nbgitpuller. This a tool for quickly pulling in GitHub content into a JupyterHub. You can create links that, when clicked, will automatically pull in content into a user’s workspace.
nbgitpuller lets you share a link with this structure:
We can take advantage of this in Binder to share a similar link with a BinderHub. Here’s how:
Step 0: Your repository structure
In this example, we’ll have two repositories. The environment repository will have all the Binder configuration files to define the environment you’d like. It’s what Binder will “build”. The content repository will only have the content you want to share, not the environment files.
Step 1: Prep your environment repository
First set up the repository with whatever environment you wish. Then, make
sure that it works with
nbgitpuller by following these steps:
requirements.txt file, make sure this line is there:
... nbgitpuller ...
postBuild file make sure this line is there to activate
... jupyter serverextension enable --py nbgitpuller --sys-prefix ...
Create an nbgitpuller Binder link
Next, create a custom Binder link that points to the content you want users to see when they click the link. To do so, use the same
nbgitpuller syntax described above along with the BinderHub
For example, here’s a Binder link that uses my
binder-sandbox repository to define the environment, and that pulls in the content from the data-8 Fall 2017 course:
You can use any URL you’d like for the “content repository”!
This should let you share Binder links that all have the same environment, but that serve users arbitrary content!