make jupyterhub a build arg
and verify that it's installed in tests
MODIFY
repo2docker/detectors.py
repo2docker/detectors.py
@@ -65,6 +65,9 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*
{% endif -%}
+# make JUPYTERHUB_VERSION a build argument
+ARG JUPYTERHUB_VERSION=0.7.2
+
EXPOSE 8888
{% if env -%}
@@ -136,6 +139,16 @@ class BuildPack(LoggingConfigurable):
and there are *some* general guarantees of ordering.
"""
+
+ jupyterhub_version = Unicode(
+ '0.7.2',
+ config=True,
+ help="""JupyterHub version to install.
+
+ In general, the JupyterHub version in the image
+ and the Hub itself should have the same version number.
+ """
+ )
packages = Set(
set(),
help="""
@@ -392,7 +405,10 @@ class BuildPack(LoggingConfigurable):
fileobj=tarf,
tag=image_spec,
custom_context=True,
- decode=True
+ buildargs={
+ 'JUPYTERHUB_VERSION': self.jupyterhub_version,
+ },
+ decode=True,
):
yield line
@@ -481,7 +497,7 @@ class PythonBuildPack(BuildPack):
r"""
pip install --no-cache-dir \
notebook==5.0.0 \
- jupyterhub==0.7.2 \
+ jupyterhub==${JUPYTERHUB_VERSION} \
ipywidgets==6.0.0 \
jupyterlab==0.24.1 && \
jupyter nbextension enable --py widgetsnbextension --sys-prefix && \
@@ -704,7 +720,10 @@ class DockerBuildPack(BuildPack):
for line in client.build(
path=os.getcwd(),
tag=image_spec,
- decode=True
+ buildargs={
+ 'JUPYTERHUB_VERSION': self.jupyterhub_version,
+ },
+ decode=True,
):
yield line
@@ -719,10 +738,11 @@ class LegacyBinderDockerBuildPack(DockerBuildPack):
USER main
WORKDIR /home/main/notebooks
ENV PATH /home/main/anaconda2/envs/python3/bin:$PATH
- RUN conda install -n python3 notebook==5.0.0 ipykernel==4.6.0 && \
- pip install jupyterhub==0.7.2 && \
- conda remove -n python3 nb_conda_kernels && \
- conda install -n root ipykernel==4.6.0 && \
+ ARG JUPYTERHUB_VERSION
+ RUN conda install -yq -n python3 notebook==5.0.0 ipykernel==4.6.0 && \
+ pip install --no-cache-dir jupyterhub==${JUPYTERHUB_VERSION} && \
+ conda remove -yq -n python3 nb_conda_kernels && \
+ conda install -yq -n root ipykernel==4.6.0 && \
/home/main/anaconda2/envs/python3/bin/ipython kernel install --sys-prefix && \
/home/main/anaconda2/bin/ipython kernel install --prefix=/home/main/anaconda2/envs/python3 && \
/home/main/anaconda2/bin/ipython kernel install --sys-prefix

MODIFY
repo2docker/files/conda/environment.yml
repo2docker/files/conda/environment.yml
@@ -5,5 +5,3 @@ dependencies:
- ipykernel==4.6.0
- ipywidgets==6.0.0
- jupyterlab==0.22.1
- - pip:
- - jupyterhub==0.7.2

MODIFY
repo2docker/files/conda/install-miniconda.bash
repo2docker/files/conda/install-miniconda.bash
@@ -30,6 +30,7 @@ ${CONDA_DIR}/bin/conda config --system --set update_dependencies false
${CONDA_DIR}/bin/conda config --system --set show_channel_urls true
${CONDA_DIR}/bin/conda env update -n root -f /tmp/environment.yml
+${CONDA_DIR}/bin/pip install --no-cache-dir jupyterhub==${JUPYTERHUB_VERSION}
# Clean things out!
${CONDA_DIR}/bin/conda clean -tipsy

MODIFY
tests/dockerfile/jupyter-stack/Dockerfile
tests/dockerfile/jupyter-stack/Dockerfile
FROM jupyter/base-notebook:b4dd11e16ae4
+ARG JUPYTERHUB_VERSION
+RUN pip install jupyterhub==$JUPYTERHUB_VERSION
+
RUN pip install there
ADD verify verify

MODIFY
tests/dockerfile/jupyter-stack/verify
tests/dockerfile/jupyter-stack/verify
#!/usr/bin/env python
+import os
import sys
assert sys.version_info[:2] == (3, 6)
import jupyter
+import jupyterhub
import there

MODIFY
tests/dockerfile/legacy/verify
tests/dockerfile/legacy/verify
#!/usr/bin/env python
+import os
import sys
-assert sys.version_info[:2] == (2, 7)
+assert sys.version_info[:2] == (3, 5), sys.version
import jupyter
+import jupyterhub

MODIFY
tests/dockerfile/simple/Dockerfile
tests/dockerfile/simple/Dockerfile
-FROM alpine:3.5
+FROM python:3.5
+
+ARG JUPYTERHUB_VERSION
+RUN pip3 install jupyterhub==$JUPYTERHUB_VERSION
ENTRYPOINT "/bin/sh"

make jupyterhub a build arg

and verify that it's installed in tests