-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
266 lines (233 loc) · 8.3 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
# Debian Jessie debootstrap from 2017-02-27
# https://github.com/docker-library/official-images/commit/aa5973d0c918c70c035ec0746b8acaec3a4d7777
FROM debian@sha256:52af198afd8c264f1035206ca66a5c48e602afb32dc912ebf9e9478134601ec4
MAINTAINER dataistanbul <[email protected]>
USER root
# Install all OS dependencies for notebook server that starts but lacks all
# features (e.g., download as all possible file formats)
ENV DEBIAN_FRONTEND noninteractive
RUN REPO=http://cdn-fastly.deb.debian.org \
&& echo "deb $REPO/debian jessie main\ndeb $REPO/debian-security jessie/updates main" > /etc/apt/sources.list \
&& apt-get update && apt-get -yq dist-upgrade \
&& apt-get install -yq --no-install-recommends \
wget \
bzip2 \
ca-certificates \
sudo \
locales \
fonts-liberation \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
# Install Tini
RUN wget --quiet https://github.com/krallin/tini/releases/download/v0.10.0/tini && \
echo "1361527f39190a7338a0b434bd8c88ff7233ce7b9a4876f3315c22fce7eca1b0 *tini" | sha256sum -c - && \
mv tini /usr/local/bin/tini && \
chmod +x /usr/local/bin/tini
# Configure environment
ENV CONDA_DIR /opt/conda
ENV PATH $CONDA_DIR/bin:$PATH
ENV SHELL /bin/bash
ENV NB_USER jovyan
ENV NB_UID 1000
ENV HOME /home/$NB_USER
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
# Create jovyan user with UID=1000 and in the 'users' group
RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER && \
mkdir -p $CONDA_DIR && \
chown $NB_USER $CONDA_DIR
USER $NB_USER
# Setup jovyan home directory
RUN mkdir /home/$NB_USER/work && \
mkdir /home/$NB_USER/.jupyter && \
echo "cacert=/etc/ssl/certs/ca-certificates.crt" > /home/$NB_USER/.curlrc
# Install conda as jovyan
RUN cd /tmp && \
mkdir -p $CONDA_DIR && \
wget --quiet https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86_64.sh && \
echo "c59b3dd3cad550ac7596e0d599b91e75d88826db132e4146030ef471bb434e9a *Miniconda3-4.2.12-Linux-x86_64.sh" | sha256sum -c - && \
/bin/bash Miniconda3-4.2.12-Linux-x86_64.sh -f -b -p $CONDA_DIR && \
rm Miniconda3-4.2.12-Linux-x86_64.sh && \
$CONDA_DIR/bin/conda config --system --add channels conda-forge && \
$CONDA_DIR/bin/conda config --system --set auto_update_conda false && \
conda clean -tipsy
# Install Jupyter Notebook and Hub
RUN conda install --quiet --yes \
'notebook=5.0.*' \
'jupyterhub=0.7.*' \
'jupyterlab=0.18.*' \
&& conda clean -tipsy
USER root
EXPOSE 8888
WORKDIR /home/$NB_USER/work
# Add local files as late as possible to avoid cache busting
COPY start.sh /usr/local/bin/
COPY start-notebook.sh /usr/local/bin/
COPY start-singleuser.sh /usr/local/bin/
COPY jupyter_notebook_config.py /home/$NB_USER/.jupyter/
RUN chown -R $NB_USER:users /home/$NB_USER/.jupyter
# Install all OS dependencies for fully functional notebook server
RUN apt-get update && apt-get install -yq --no-install-recommends \
git \
vim \
jed \
emacs \
build-essential \
python-dev \
unzip \
libsm6 \
pandoc \
texlive-latex-base \
texlive-latex-extra \
texlive-fonts-extra \
texlive-fonts-recommended \
texlive-generic-recommended \
texlive-xetex \
lmodern \
libxrender1 \
inkscape \
ssh \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
# libav-tools for matplotlib anim
RUN apt-get update && \
apt-get install -y --no-install-recommends libav-tools && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER $NB_USER
# Install Python 3 packages
# Remove pyqt and qt pulled in for matplotlib since we're only ever going to
# use notebook-friendly backends in these images
RUN conda install --quiet --yes \
'nomkl' \
'ipywidgets=6.0*' \
'pandas=0.19*' \
'numexpr=2.6*' \
'matplotlib=2.0*' \
'scipy=0.19*' \
'seaborn=0.7*' \
'scikit-learn=0.18*' \
'scikit-image=0.12*' \
'sympy=1.0*' \
'cython=0.25*' \
'patsy=0.4*' \
'statsmodels=0.8*' \
'cloudpickle=0.2*' \
'dill=0.2*' \
'numba=0.31*' \
'bokeh=0.12*' \
'sqlalchemy=1.1*' \
'hdf5=1.8.17' \
'h5py=2.6*' \
'vincent=0.4.*' \
'beautifulsoup4=4.5.*' \
'xlrd' && \
conda remove --quiet --yes --force qt pyqt && \
conda clean -tipsy
# Activate ipywidgets extension in the environment that runs the notebook server
RUN jupyter nbextension enable --py widgetsnbextension --sys-prefix
# Install Python 2 packages
# Remove pyqt and qt pulled in for matplotlib since we're only ever going to
# use notebook-friendly backends in these images
RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 \
'nomkl' \
'ipython=5.3*' \
'ipywidgets=6.0*' \
'pandas=0.19*' \
'numexpr=2.6*' \
'matplotlib=2.0*' \
'scipy=0.19*' \
'seaborn=0.7*' \
'scikit-learn=0.18*' \
'scikit-image=0.12*' \
'sympy=1.0*' \
'cython=0.25*' \
'patsy=0.4*' \
'statsmodels=0.8*' \
'cloudpickle=0.2*' \
'dill=0.2*' \
'numba=0.31*' \
'bokeh=0.12*' \
'hdf5=1.8.17' \
'h5py=2.6*' \
'sqlalchemy=1.1*' \
'pyzmq' \
'vincent=0.4.*' \
'beautifulsoup4=4.5.*' \
'xlrd' && \
conda remove -n python2 --quiet --yes --force qt pyqt && \
conda clean -tipsy
# Add shortcuts to distinguish pip for python2 and python3 envs
RUN ln -s $CONDA_DIR/envs/python2/bin/pip $CONDA_DIR/bin/pip2 && \
ln -s $CONDA_DIR/bin/pip $CONDA_DIR/bin/pip3
# Import matplotlib the first time to build the font cache.
ENV XDG_CACHE_HOME /home/$NB_USER/.cache/
RUN MPLBACKEND=Agg $CONDA_DIR/envs/python2/bin/python -c "import matplotlib.pyplot"
# Configure ipython kernel to use matplotlib inline backend by default
RUN mkdir -p $HOME/.ipython/profile_default/startup
COPY mplimporthook.py $HOME/.ipython/profile_default/startup/
USER root
# Install Python 2 kernel spec globally to avoid permission problems when NB_UID
# switching at runtime and to allow the notebook server running out of the root
# environment to find it. Also, activate the python2 environment upon kernel
# launch.
RUN pip install kernda --no-cache && \
$CONDA_DIR/envs/python2/bin/python -m ipykernel install && \
kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json && \
pip uninstall kernda -y
# R pre-requisites
RUN apt-get update && \
apt-get install -y --no-install-recommends \
fonts-dejavu \
gfortran \
gcc && apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Julia dependencies
RUN echo "deb http://ppa.launchpad.net/staticfloat/juliareleases/ubuntu trusty main" > /etc/apt/sources.list.d/julia.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3D3D3ACC && \
apt-get update && \
apt-get install -y --no-install-recommends \
julia \
libnettle4 && apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER $NB_USER
# R packages including IRKernel which gets installed globally.
RUN conda config --add channels r && \
conda install --quiet --yes \
'rpy2=2.8*' \
'r-base=3.3.2' \
'r-irkernel=0.7*' \
'r-plyr=1.8*' \
'r-devtools=1.12*' \
'r-tidyverse=1.0*' \
'r-shiny=0.14*' \
'r-rmarkdown=1.2*' \
'r-forecast=7.3*' \
'r-rsqlite=1.1*' \
'r-reshape2=1.4*' \
'r-nycflights13=0.2*' \
'r-caret=6.0*' \
'r-rcurl=1.95*' \
'r-crayon=1.3*' \
'r-randomforest=4.6*' && conda clean -tipsy
# Install IJulia packages as jovyan and then move the kernelspec out
# to the system share location. Avoids problems with runtime UID change not
# taking effect properly on the .local folder in the jovyan home dir.
RUN julia -e 'Pkg.add("IJulia")' && \
mv $HOME/.local/share/jupyter/kernels/julia* $CONDA_DIR/share/jupyter/kernels/ && \
chmod -R go+rx $CONDA_DIR/share/jupyter && \
rm -rf $HOME/.local
# Show Julia where conda libraries are
# Add essential packages
RUN echo "push!(Libdl.DL_LOAD_PATH, \"$CONDA_DIR/lib\")" > /home/$NB_USER/.juliarc.jl && \
julia -e 'Pkg.add("Gadfly")' && julia -e 'Pkg.add("RDatasets")' && julia -F -e 'Pkg.add("HDF5")'
# Precompile Julia pakcages
RUN julia -e 'using IJulia' && julia -e 'using Gadfly' && julia -e 'using RDatasets'&& julia -e 'using HDF5'
# Configure container startup
ENTRYPOINT ["tini", "--"]
CMD ["start-notebook.sh"]