-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
183 lines (161 loc) · 6.18 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
################################################################################
# Setup builder stage OS
################################################################################
FROM centos:latest as builder
# Configure environment
ENV CONDA_DIR=/opt/conda \
SHELL=/bin/bash \
NB_USER=jovyan \
NB_UID=1000 \
NB_GID=100 \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ENV PATH=$CONDA_DIR/bin:$PATH \
HOME=/home/$NB_USER
# copy in necessary files
COPY util/* $CONDA_DIR/bin/
# initial installs using yum
USER root
RUN yum -y update \
&& yum -y install \
curl \
bzip2 \
sudo \
gcc \
epel-release
# create jovyan user with UID=1000 and in the 'users' group
# and make sure these dirs are writable by the `users` group.
RUN echo "### Creation of jovyan user account" \
&& useradd -m -s /bin/bash -N -u $NB_UID $NB_USER \
&& mkdir -p $CONDA_DIR \
&& chown -R $NB_USER:$NB_GID $CONDA_DIR \
&& chown -R $NB_USER:$NB_GID $HOME \
&& fix-permissions $HOME \
&& fix-permissions $CONDA_DIR \
# grant user account sudo privilidge
&& echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook
# miniconda installation
USER $NB_UID
COPY --chown=1000:100 config/jupyter $HOME/.jupyter/
COPY --chown=1000:100 config/ipydeps $HOME/.config/ipydeps/
RUN curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh \
&& echo "### Installing miniconda" \
&& bash /tmp/miniconda.sh -bfp $CONDA_DIR \
&& rm -rf /tmp/miniconda.sh
# core jupyter installation using conda
RUN conda update conda \
&& echo "### Installs using conda" \
&& conda install -y \
"python=3" \
"notebook<5.3" \
"ipywidgets<7" \
"tornado<5" \
make \
ruby
# additional desired packages using pip
RUN echo "### Installs using pip" \
&& pip --no-cache-dir install \
bash_kernel \
jupyter_c_kernel==1.0.0 \
jupyter_dashboards \
ordo \
pypki2 \
ipydeps \
jupyter_nbextensions_configurator \
http://github.com/nbgallery/nbgallery-extensions/tarball/master#egg=jupyter_nbgallery
# Add simple kernels (no extra apks)
COPY kernels/installers/install_c_kernel $CONDA_DIR/share/jupyter/kernels/installers/
RUN echo "### Activate simple kernels" \
&& python -m bash_kernel.install --prefix=$CONDA_DIR \
&& python $CONDA_DIR/share/jupyter/kernels/installers/install_c_kernel --prefix=$CONDA_DIR \
# Other pip package installation and enabling
&& echo "### Activate jupyter extensions" \
&& jupyter nbextensions_configurator enable --prefix=$CONDA_DIR \
&& jupyter nbextension enable --py --sys-prefix widgetsnbextension \
&& jupyter serverextension enable --py jupyter_nbgallery \
&& jupyter nbextension install --prefix=$CONDA_DIR --py jupyter_nbgallery \
&& jupyter nbextension enable jupyter_nbgallery --py \
&& jupyter nbextension install --prefix=$CONDA_DIR --py ordo \
&& jupyter nbextension enable ordo --py
# Patches? Do we still need them? They go here
RUN echo "### Patching" \
&& sed -i 's/_max_upload_size_mb = [0-9][0-9]/_max_upload_size_mb = 50/g' \
$CONDA_DIR/lib/python3*/site-packages/notebook/static/tree/js/notebooklist.js \
$CONDA_DIR/lib/python3*/site-packages/notebook/static/tree/js/main.min.js \
$CONDA_DIR/lib/python3*/site-packages/notebook/static/tree/js/main.min.js.map
# another last cleanup
RUN echo "### Final stage-one cleanup" \
&& conda clean --all --yes \
&& clean-pyc-files $CONDA_DIR/ \
&& find $CONDA_DIR/ -regex ".*/tests?" -type d -print0 | xargs -r0 -- rm -r ; exit 0
# add in all the dynamic kernels
COPY kernels/R_small $CONDA_DIR/share/jupyter/kernels/R_small
COPY kernels/R_big $CONDA_DIR/share/jupyter/kernels/R_big
COPY kernels/ruby $CONDA_DIR/share/jupyter/kernels/ruby
COPY kernels/python2 $CONDA_DIR/share/jupyter/kernels/python2
COPY kernels/javascript $CONDA_DIR/share/jupyter/kernels/javascript
COPY kernels/installers/dynamic* $CONDA_DIR/share/jupyter/kernels/installers/
################################################################################
# second stage
# - starts from scratch centos
# - copies in the /opt/conda and /home/jovyan directories
# - cleans up
################################################################################
FROM centos:latest
MAINTAINER [email protected]
# Add Tini
ENV TINI_VERSION=v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
# resetup ENV variables
ENV CONDA_DIR=/opt/conda \
SHELL=/bin/bash \
NB_USER=jovyan \
NB_UID=1000 \
NB_GID=100 \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
ENV PATH=$CONDA_DIR/bin:$PATH \
HOME=/home/$NB_USER \
JUPYTER=/opt/conda/bin/jupyter
ENV GOPATH=$HOME/.local/share/go \
LGOPATH=$HOME/.local/share/lgo
# second stage install packages and cleanup
USER root
RUN yum -y update \
&& yum -y install \
sudo \
gcc \
epel-release \
# git \
&& echo "### second layer cleanup" \
&& yum clean all \
&& rpm --rebuilddb \
&& rm -rf /var/cache/yum \
/bin/bashbug \
/usr/local/share/man/* \
/usr/bin/gprof \
&& find /usr/share/terminfo -type f -delete \
&& chmod +x /tini \
&& echo "$NB_USER ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/notebook \
&& echo "### Creation of jovyan user account" \
&& useradd -s /bin/bash -N -u $NB_UID $NB_USER \
&& rm -rf $HOME
# copy in built package from base layer
COPY --chown=1000:100 --from=builder $CONDA_DIR $CONDA_DIR
COPY --chown=1000:100 --from=builder $HOME $HOME
# set startpoints
EXPOSE 80 443
ENTRYPOINT ["/tini", "--"]
USER $NB_UID
WORKDIR $HOME
# start notebook
CMD ["jupyter-notebook-insecure"]
########################################################################
# Metadata
########################################################################
ENV NBGALLERY_CLIENT_VERSION=8.0.0
LABEL gallery.nb.version=$NBGALLERY_CLIENT_VERSION \
gallery.nb.description="Centos-based Jupyter notebook server" \
gallery.nb.URL="https://github.com/nbgallery/jupyter-centos"