2017-11-21 20:24:43 +01:00
|
|
|
FROM continuumio/anaconda3
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get upgrade -y \
|
|
|
|
&& apt-get install -y \
|
2017-11-27 17:16:51 +01:00
|
|
|
libpq-dev \
|
|
|
|
build-essential \
|
|
|
|
git \
|
|
|
|
sudo \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
RUN conda install -y -c conda-forge \
|
2017-12-04 11:33:16 +01:00
|
|
|
tensorflow \
|
2017-11-27 17:16:51 +01:00
|
|
|
jupyter_contrib_nbextensions
|
|
|
|
|
|
|
|
ARG username
|
2017-11-28 10:33:20 +01:00
|
|
|
ARG userid
|
2017-11-27 17:16:51 +01:00
|
|
|
|
2017-12-04 11:33:16 +01:00
|
|
|
ARG home=/home/${username}
|
|
|
|
ARG workdir=${home}/handson-ml
|
|
|
|
|
2017-11-29 16:20:07 +01:00
|
|
|
RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
|
|
|
|
&& echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} \
|
|
|
|
&& chmod 0440 /etc/sudoers.d/${username}
|
2017-11-27 17:16:51 +01:00
|
|
|
|
2017-11-30 12:09:16 +01:00
|
|
|
WORKDIR ${workdir}
|
|
|
|
RUN chown ${username}:${username} ${workdir}
|
2017-11-27 17:16:51 +01:00
|
|
|
|
|
|
|
USER ${username}
|
|
|
|
|
|
|
|
RUN jupyter contrib nbextension install --user
|
|
|
|
RUN jupyter nbextension enable toc2/main
|
|
|
|
|
|
|
|
|
2017-12-01 10:56:36 +01:00
|
|
|
# INFO: Jupyter and nbdime extension are not totally integrated (anaconda image is py36,
|
|
|
|
# nbdime checks for py35 at the moment, still the config below enables diffing
|
|
|
|
# notebooks with nbdiff (and nbdiff support in git diff command) after connecting
|
|
|
|
# to the container by "make exec" (or "docker-compose exec handson-ml bash")
|
|
|
|
# You may also try running:
|
|
|
|
# nbd NOTEBOOK_NAME.ipynb
|
|
|
|
# to get nbdiff between checkpointed version and current version of the given notebook
|
2017-11-27 17:16:51 +01:00
|
|
|
USER root
|
|
|
|
WORKDIR /
|
|
|
|
RUN conda install -y -c conda-forge nbdime
|
|
|
|
USER ${username}
|
2017-11-30 12:09:16 +01:00
|
|
|
WORKDIR ${workdir}
|
2017-11-21 20:24:43 +01:00
|
|
|
|
2017-11-29 16:20:07 +01:00
|
|
|
RUN git-nbdiffdriver config --enable --global
|
|
|
|
|
2017-12-01 10:56:36 +01:00
|
|
|
# INFO: Optionally uncomment any (one) of the following RUN commands below to ignore either
|
2017-11-30 12:09:16 +01:00
|
|
|
# metadata or details in nbdiff within git diff
|
2017-11-29 16:20:07 +01:00
|
|
|
#RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-metadata'
|
2017-12-01 10:56:36 +01:00
|
|
|
RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-details'
|
2017-11-30 12:09:16 +01:00
|
|
|
|
|
|
|
|
2017-12-01 11:28:18 +01:00
|
|
|
# INFO: Dirty nbdime patching (ignored if not matching)
|
2017-11-30 12:09:16 +01:00
|
|
|
COPY docker/nbdime-*.patch /tmp/
|
|
|
|
USER root
|
|
|
|
WORKDIR /
|
|
|
|
RUN patch -d /opt/conda/lib/python3.6/site-packages -p1 --forward --reject-file=- < \
|
2017-12-04 11:33:16 +01:00
|
|
|
/tmp/nbdime-1-details.patch || true \
|
2017-11-30 12:09:16 +01:00
|
|
|
&& patch -d /opt/conda/lib/python3.6/site-packages -p1 --forward --reject-file=- < \
|
2017-12-01 11:28:18 +01:00
|
|
|
/tmp/nbdime-2-toc.patch || true
|
2017-11-30 12:09:16 +01:00
|
|
|
RUN rm /tmp/nbdime-*.patch
|
|
|
|
USER ${username}
|
|
|
|
WORKDIR ${workdir}
|
2017-11-29 16:20:07 +01:00
|
|
|
|
2017-11-28 09:57:47 +01:00
|
|
|
|
2017-11-27 17:16:51 +01:00
|
|
|
COPY docker/bashrc /tmp/bashrc
|
2017-12-04 11:33:16 +01:00
|
|
|
RUN cat /tmp/bashrc >> ${home}/.bashrc
|
2017-12-09 20:17:56 +01:00
|
|
|
RUN echo "export PATH=\"${workdir}/docker/bin:$PATH\"" >> ${home}/.bashrc
|
2017-11-30 12:09:16 +01:00
|
|
|
RUN sudo rm /tmp/bashrc
|
2017-11-30 12:59:26 +01:00
|
|
|
|
2017-12-01 10:56:36 +01:00
|
|
|
# INFO: Uncomment the RUN command below to disable git diff paging
|
|
|
|
#RUN git config --global core.pager ''
|
2017-11-30 12:59:26 +01:00
|
|
|
|
2017-12-01 10:56:36 +01:00
|
|
|
# INFO: Uncomment the RUN command below for easy and constant notebook URL (just localhost:8888)
|
|
|
|
# That will switch jupyter to using empty password instead of a token.
|
|
|
|
# To avoid making a security hole you SHOULD in fact not only uncomment but
|
|
|
|
# regenerate the hash for your own non-empty password and replace the hash below.
|
|
|
|
# You can compute a password hash in any notebook, just run the code:
|
|
|
|
# from notebook.auth import passwd
|
|
|
|
# passwd()
|
|
|
|
# and take the hash from the output
|
2017-12-04 11:33:16 +01:00
|
|
|
#RUN mkdir -p ${home}/.jupyter && \
|
2017-12-01 10:56:36 +01:00
|
|
|
# echo 'c.NotebookApp.password = u"sha1:c6bbcba2d04b:f969e403db876dcfbe26f47affe41909bd53392e"' \
|
2017-12-04 11:33:16 +01:00
|
|
|
# >> ${home}/.jupyter/jupyter_notebook_config.py
|