move dockerfile appendix into LegacyBinderDockerBuildPack.dockerfile_appendix
and make it overrideable
import os
import sys
import subprocess
+from textwrap import dedent
import docker
from docker.utils import kwargs_from_env
@@ -50,7 +51,11 @@ class DockerBuildPack(BuildPack):
else:
sys.stdout.write(progress['stream'])
-_legacy_binder_docker_appendix = """
+
+class LegacyBinderDockerBuildPack(DockerBuildPack):
+
+ name = Unicode('Legacy Binder Dockerfile')
+ dockerfile_appendix = Unicode(dedent(r"""
USER root
COPY . /home/main/notebooks
RUN chown -R main:main /home/main/notebooks
@@ -65,11 +70,8 @@ RUN conda install -n python3 notebook==5.0.0 ipykernel==4.6.0 && \
/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):
+ """), config=True)
- name = Unicode('Legacy Binder Dockerfile')
def detect(self, workdir):
dockerfile = os.path.join(workdir, 'Dockerfile')
if not os.path.exists(dockerfile):
@@ -86,8 +88,9 @@ class LegacyBinderDockerBuildPack(DockerBuildPack):
return False
def amend_dockerfile(self, dockerfile):
+ print(self.dockerfile_appendix)
with open(dockerfile, 'a') as f:
- f.write(_legacy_binder_docker_appendix)
+ f.write(self.dockerfile_appendix)
class S2IBuildPack(BuildPack):
