Common tasks#
These are some common tasks to be done as a part of developing and maintaining repo2docker. If you’d like more guidance for how to do these things, reach out in the JupyterHub Gitter channel.
Set up your development environment first!
Before attempting most tasks, follow the directions to set up your development environment.
Though note that many of these tasks do not require Docker.
Running tests#
We have a lot of tests for various cases supported by repo2docker in the tests/
subdirectory. If you fix a bug or add new functionality consider adding a new
test to prevent the bug from coming back. These use
py.test.
You can run all the tests with:
py.test -s tests/*
If you want to run a specific test, you can do so with:
py.test -s tests/<path-to-test>
To skip the tests related to Mercurial repositories (to avoid to install
Mercurial and hg-evolve), one can use the environment variable
REPO2DOCKER_SKIP_HG_TESTS.
Troubleshooting Tests#
Some of the tests have non-python requirements for your development machine. They are:
git-lfsmust be installed (instructions). It need not be activated – there is no need to run thegit lfs installcommand. It just needs to be available to the test suite.If your test failure messages include “
git-lfs filter-process: git-lfs: command not found”, this step should address the problem.
Minimum Docker Image size of
128GBis required. If you are not running Docker on a Linux OS, you may need to expand the runtime image size for your installation. See Docker’s instructions for macOS or instructions for Windows 10 for more information.If your test failure messages include “
No space left on device: '/home/...”, this step should address the problem.
Update and Freeze BuildPack Dependencies#
This section covers the process by which repo2docker defines and updates the dependencies that are installed by default for several buildpacks.
For both the conda and virtualenv (pip) base environments in the Conda BuildPack and Python BuildPack,
we install specific pinned versions of all dependencies. We explicitly list the dependencies
we want, then freeze them at commit time to explicitly list all the
transitive dependencies at current versions. This way, we know that
all dependencies will have the exact same version installed at all times.
To update one of the dependencies shared across all repo2docker builds, you
must follow these steps (with more detailed information in the sections below):
Bump the version numbers of the dependencies you want to update in the
condaenvironment (link)Make a pull request with your changes (link)
See the subsections below for more detailed instructions.
Conda dependencies#
There are two files related to conda dependencies. Edit as needed.
repo2docker/buildpacks/conda/environment.ymlContains list of packages to install in Python3 conda environments, which are the default. This is where all Notebook versions & notebook extensions (such as JupyterLab) go.
repo2docker/buildpacks/conda/environment.py-2.7.ymlContains list of packages to install in Python2 conda environments, which can be specifically requested by users. This only needs
IPyKerneland kernel related libraries. Notebook / Notebook Extension need not be installed here.
Once you edit either of these files to add a new package / bump version on an existing package, you should then run:
cd ./repo2docker/buildpacks/conda/ python freeze.py
This script will resolve dependencies and write them to the respective
.lockfiles.After the freeze script finishes, a number of files will have been modified. They roughly follow this pattern:
repo2docker/buildpacks/conda/environment*
You should commit all modified files to git.
Make a Pull Request to the
jupyterhub/repo2dockerrepository, with a description of what versions were bumped / what new packages were added and why. If you fix a bug or add new functionality consider adding a new test to prevent the bug from coming back/the feature breaking in the future.Once the pull request is approved (but not yet merged), Update the change log (details below) and commit the change log, then update the pull request.
Creating a Release#
We encourage a release of whatever is on main every month. We use “calendar versioning”.
A new release will automatically be created when a new git tag is created and pushed to the repository. See previous releases for examples.
To create a new release, follow these steps:
Add the output of
github-activitybetween now and last release, to the changelog and open a PR with this contentE.g. the activity since the date of the last release:
github-activity jupyterhub/repo2docker -s 2025-08-01
Go to the GitHub repository
Click
Draft a new releaseClick
TagType in a new tag like
YYYY.MM.N(whereNis the release number this month, usually it is0)
Title:
<Month> <Year>(E.g.,August 2025)Body: Paste the
github-activityoutput from the changelogClick
Publish release
This will create a new release and a new tag.
The creation of the tag will trigger the .github/workflows/release.yml action to publish the latest repo2docker package to PyPI.
You can confirm the new package is released in our PyPI page.
Uncommon tasks#
Compare generated Dockerfiles between repo2docker versions#
For larger refactorings it can be useful to check that the generated Dockerfiles match between an older version of r2d and the current version. The following shell script automates this test.
#! /bin/bash -e
current_version=$(repo2docker --version | sed s@+@-@)
echo "Comparing $(pwd) (local $current_version vs. $R2D_COMPARE_TO)"
basename="dockerfilediff"
diff_r2d_dockerfiles_with_version () {
docker run --rm -t -v "$(pwd)":"$(pwd)" --user 1000 jupyterhub/repo2docker:"$1" repo2docker --no-build --debug "$(pwd)" &> "$basename"."$1"
repo2docker --no-build --debug "$(pwd)" &> "$basename"."$current_version"
# remove first line logging the path
sed -i '/^\[Repo2Docker\]/d' "$basename"."$1"
sed -i '/^\[Repo2Docker\]/d' "$basename"."$current_version"
diff --strip-trailing-cr "$basename"."$1" "$basename"."$current_version" | colordiff
rm "$basename"."$current_version" "$basename"."$1"
}
startdir="$(pwd)"
cd "$1"
#diff_r2d_dockerfiles 0.10.0-22.g4f428c3.dirty
diff_r2d_dockerfiles_with_version "$R2D_COMPARE_TO"
cd "$startdir"
Put the code above in a file tests/dockerfile_diff.sh and make it executable: chmod +x dockerfile_diff.sh.
Configure the repo2docker version you want to compare with your local version in the environment variable R2D_COMPARE_TO.
The scripts takes one input: the directory where repo2docker should be executed.
cd tests/
R2D_COMPARE_TO=0.10.0 ./dockerfile_diff.sh venv/py35/
Run it for all directories where there is a verify file:
cd tests/
R2D_COMPARE_TO=0.10.0 CMD=$(pwd)/dockerfile_diff.sh find . -name 'verify' -execdir bash -c '$CMD $(pwd)' \;
To keep the created Dockefilers for further inspection, comment out the deletion line in the script.