=========================================
``irfpy.aspera`` stable version on Docker
=========================================

The stable version of the Dockerfile is at https://irfpy.irf.se/projects/aspera/Dockerfile

Create an image
---------------

To create an image, you can use the command

.. code-block:: sh

        docker build -t irfpy/aspera https://irfpy.irf.se/projects/aspera/Dockerfile

Running ipython
---------------

To run the container, you may need to optimize some parameters.

- ``data_location``: The location where irfpy dataset is stored.
- ``local_work_directory``: The local working directory.

.. code-block:: sh

        docker run -it \
                -v <data_location>:/Volumes/scidata/data \
                -v <local_work_directory>:/notebooks irfpy/aspera \
                ipython

For example, you may use

.. code-block:: sh

        docker run -it --rm \
                -v /Volumes/scidata256/data:/Volumes/scidata/data \
                -v $(pwd):/notebooks irfpy/aspera \
                ipython

Then ipython is launched.

.. code-block:: python

        In [1]: import irfpy.aspera
        In [2]: print(irfpy.aspera.__version__)
        4.3.14

Running Jupyter Notebook
------------------------

To run the Jupyter notebook, one should also specify the local port to be opened.

- local_port: The listening port for Jupyter.

.. code-block:: sh

        docker run --rm -it \
                -p <local_port>:8888 \
                -v <data_location>:/Volumes/scidata/data \
                -v <local_work_directory>:/notebooks irfpy/aspera \
                bash -c "/opt/conda/bin/jupyter notebook --notebook-dir=/notebooks --ip=0.0.0.0 --port=8888 --no-browser --allow-root"

For example,

.. code-block:: sh

        docker run --rm -it \
                -p 8888:8888 \
                -v /Volumes/scidata256/data:/Volumes/scidata/data \
                -v $(pwd):/notebooks irfpy/aspera \
                bash -c "/opt/conda/bin/jupyter notebook --notebook-dir=/notebooks --ip=0.0.0.0 --port=8888 --no-browser --allow-root"

Then, you can connect to the localhost with the specified local port:
http://127.0.0.1:8888/?token=6a39e5adb9c49093cf589015af14a36e102ad81cf62f98ad
Note that the token changes every time.