kopia lustrzana https://github.com/jupyterhub/repo2docker
move dockerfile appendix into LegacyBinderDockerBuildPack.dockerfile_appendix
and make it overrideablepull/16/head
rodzic
766eee29e6
commit
82ccb38e3a
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from textwrap import dedent
|
||||||
|
|
||||||
import docker
|
import docker
|
||||||
from docker.utils import kwargs_from_env
|
from docker.utils import kwargs_from_env
|
||||||
|
@ -50,26 +51,27 @@ class DockerBuildPack(BuildPack):
|
||||||
else:
|
else:
|
||||||
sys.stdout.write(progress['stream'])
|
sys.stdout.write(progress['stream'])
|
||||||
|
|
||||||
_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):
|
class LegacyBinderDockerBuildPack(DockerBuildPack):
|
||||||
|
|
||||||
name = Unicode('Legacy Binder Dockerfile')
|
name = Unicode('Legacy Binder Dockerfile')
|
||||||
|
dockerfile_appendix = Unicode(dedent(r"""
|
||||||
|
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
|
||||||
|
"""), config=True)
|
||||||
|
|
||||||
def detect(self, workdir):
|
def detect(self, workdir):
|
||||||
dockerfile = os.path.join(workdir, 'Dockerfile')
|
dockerfile = os.path.join(workdir, 'Dockerfile')
|
||||||
if not os.path.exists(dockerfile):
|
if not os.path.exists(dockerfile):
|
||||||
|
@ -86,8 +88,9 @@ class LegacyBinderDockerBuildPack(DockerBuildPack):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def amend_dockerfile(self, dockerfile):
|
def amend_dockerfile(self, dockerfile):
|
||||||
|
print(self.dockerfile_appendix)
|
||||||
with open(dockerfile, 'a') as f:
|
with open(dockerfile, 'a') as f:
|
||||||
f.write(_legacy_binder_docker_appendix)
|
f.write(self.dockerfile_appendix)
|
||||||
|
|
||||||
|
|
||||||
class S2IBuildPack(BuildPack):
|
class S2IBuildPack(BuildPack):
|
||||||
|
|
Ładowanie…
Reference in New Issue