add legacy binder dockerfile buildpack

- stages files, which previous binder did automatically and repo2docker does not
- installs required versions of ipykernel, jupyterhub, notebook
- registers kernelspecs explicitly
- launches notebook server with python3 env
- removes nb_conda_kernels, which was causing trouble
- sets JUPYTER_PATH so kernelspecs and extensions that were being installed into the python 2 env will still be picked up
pull/16/head
Min RK 2017-05-25 15:15:00 -07:00
rodzic db66f1dc06
commit 766eee29e6
2 zmienionych plików z 43 dodań i 3 usunięć

Wyświetl plik

@ -24,7 +24,10 @@ from docker.utils import kwargs_from_env
import subprocess
from .detectors import BuildPack, PythonBuildPack, DockerBuildPack, CondaBuildPack
from .detectors import (
BuildPack, PythonBuildPack, DockerBuildPack, LegacyBinderDockerBuildPack,
CondaBuildPack,
)
from .utils import execute_cmd
from . import __version__
@ -90,7 +93,7 @@ class Repo2Docker(Application):
buildpacks = List(
Type(BuildPack),
[DockerBuildPack, CondaBuildPack, PythonBuildPack],
[LegacyBinderDockerBuildPack, DockerBuildPack, CondaBuildPack, PythonBuildPack],
config=True,
help="""
Ordered list of BuildPacks to try to use to build a git repository.

Wyświetl plik

@ -50,7 +50,44 @@ class DockerBuildPack(BuildPack):
else:
sys.stdout.write(progress['stream'])
_legacybinder_docker_appendix = """
_legacy_binder_docker_appendix = """
USER root
COPY . /home/main/notebooks
RUN chown -R main:main /home/main/notebooks
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 && \
/home/main/anaconda2/envs/python3/bin/ipython kernel install --sys-prefix && \
/home/main/anaconda2/bin/ipython kernel install --prefix=/home/main/anaconda2/envs/python3
ENV JUPYTER_PATH /home/main/anaconda2/share/jupyter:$JUPYTER_PATH
CMD jupyter notebook --ip 0.0.0.0
"""
class LegacyBinderDockerBuildPack(DockerBuildPack):
name = Unicode('Legacy Binder Dockerfile')
def detect(self, workdir):
dockerfile = os.path.join(workdir, 'Dockerfile')
if not os.path.exists(dockerfile):
return False
with open(dockerfile, 'r') as f:
for line in f:
if line.startswith('FROM'):
if 'andrewosh/binder-base' in line.split('#')[0].lower():
self.amend_dockerfile(dockerfile)
return True
else:
return False
# No FROM?!
return False
def amend_dockerfile(self, dockerfile):
with open(dockerfile, 'a') as f:
f.write(_legacy_binder_docker_appendix)
class S2IBuildPack(BuildPack):