repo2docker/docs/source/usage.rst

123 wiersze
4.2 KiB
ReStructuredText
Czysty Zwykły widok Historia

2017-12-07 18:50:46 +00:00
.. _usage:
=====================
2017-12-07 18:50:46 +00:00
Using ``repo2docker``
=====================
.. note::
`Docker <https://docs.docker.com/>`_ **must be running** in
order to run ``repo2docker``. For more information on installing
``repo2docker``, see :ref:`install`.
2017-12-07 18:50:46 +00:00
``repo2docker`` is called with a URL/path to a git repository. It then
performs these steps:
2017-12-07 18:50:46 +00:00
1. Inspects the repository for :ref:`configuration files <config-files>`. These will be used to build
the environment needed to run the repository.
2. Builds a Docker image with an environment specified in these :ref:`configuration files <config-files>`.
3. Runs a Jupyter server within the image that lets you explore the
repository interactively (optional)
4. Pushes the images to a Docker registry so that it may be accessed remotely
(optional)
2017-12-07 18:50:46 +00:00
Calling repo2docker
===================
2018-03-15 16:02:12 +00:00
2018-07-05 18:25:43 +00:00
repo2docker is called with this command::
2017-12-07 18:50:46 +00:00
jupyter-repo2docker <URL-or-path to repository>
2017-12-07 18:50:46 +00:00
where ``<URL-or-path to repository>`` is a URL or path to the source repository
for which you'd like to build an image.
2017-12-07 18:50:46 +00:00
For example, the following command will build an image of Peter Norvig's
Pytudes_ repository::
2017-12-12 17:59:08 +00:00
jupyter-repo2docker https://github.com/norvig/pytudes
2017-12-12 17:59:08 +00:00
Building the image may take a few minutes.
Pytudes_
uses a `requirements.txt file <https://github.com/norvig/pytudes/blob/master/requirements.txt>`_
to specify its Python environment. Because of this, ``repo2docker`` will use
``pip`` to install dependencies listed in this ``requirement.txt`` file, and
these will be present in the generated Docker image. To learn more about
configuration files in ``repo2docker`` visit :ref:`config-files`.
When the image is built, a message will be output to your terminal::
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://0.0.0.0:36511/?token=f94f8fabb92e22f5bfab116c382b4707fc2cade56ad1ace0
Pasting the URL into your browser will open Jupyter Notebook with the
dependencies and contents of the source repository in the built image.
Building a specific branch, commit or tag
=========================================
To build a particular branch and commit, use the argument ``--ref`` and
specify the ``branch-name`` or ``commit-hash``. For example::
2017-12-12 17:59:08 +00:00
jupyter-repo2docker --ref 9ced85dd9a84859d0767369e58f33912a214a3cf https://github.com/norvig/pytudes
2017-12-07 18:50:46 +00:00
.. tip::
For reproducible builds, we recommend specifying a commit-hash to
deterministically build a fixed version of a repository. Not specifying a
commit-hash will result in the latest commit of the repository being built.
2018-07-05 18:25:43 +00:00
2018-06-27 01:01:13 +00:00
Where to put configuration files
================================
2018-07-02 03:51:40 +00:00
``repo2docker`` will look for configuration files in either:
2018-07-02 03:51:40 +00:00
* A folder named ``binder/`` in the root of the repository.
2019-04-27 21:28:50 +00:00
* A folder named ``.binder/`` in the root of the repository.
* The root directory of the repository.
2017-12-07 18:50:46 +00:00
2019-04-27 21:28:50 +00:00
If either the folder ``binder/`` or ``.binder/`` is located at the top level of
the repository, only configuration files in that folder will be considered.
Check the complete list of :ref:`configuration files <config-files>` supported
by ``repo2docker`` to see how to configure the build process.
.. note::
2019-03-27 20:54:50 +00:00
``repo2docker`` builds an environment with Python 3.7 by default. If you'd
like a different version, you can specify this in your
:ref:`configuration files <config-files>`.
Debugging repo2docker with ``--debug`` and ``--no-build``
=========================================================
To debug the docker image being built, pass the ``--debug`` parameter:
.. code-block:: bash
jupyter-repo2docker --debug https://github.com/norvig/pytudes
This will print the generated ``Dockerfile``, build it, and run it.
To see the generated ``Dockerfile`` without actually building it,
pass ``--no-build`` to the commandline. This ``Dockerfile`` output
2018-03-15 18:34:39 +00:00
is for **debugging purposes** of ``repo2docker`` only - it can not
be used by docker directly.
2017-12-07 18:50:46 +00:00
.. code-block:: bash
2017-12-07 18:50:46 +00:00
jupyter-repo2docker --no-build --debug https://github.com/norvig/pytudes
2018-12-17 19:06:32 +00:00
Command line API
================
.. autoprogram:: repo2docker.__main__:argparser
:prog: jupyter-repo2docker
.. _Pytudes: https://github.com/norvig/pytudes