-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile-jupyter-master
206 lines (167 loc) · 5.86 KB
/
Dockerfile-jupyter-master
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
# Stand on the shoulders of giants
FROM jupyter/minimal-notebook
LABEL maintainer="Vishwesh Ravi Shrimali <[email protected]>"
USER root
ENV DEBIAN_FRONTEND noninteractive
# Setup Environment Variable
ENV cvVersionChoice=2
ENV cvVersion="master"
ENV cwd="/opt"
WORKDIR $cwd
RUN apt-get update && \
apt-get remove -y \
x264 libx264-dev && \
apt-get install -y \
build-essential \
libx11-dev \
libboost-python-dev \
checkinstall \
cmake \
pkg-config \
yasm \
unzip \
git \
gfortran \
libjpeg8-dev \
libpng-dev \
software-properties-common && \
add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main" && \
apt -y update && \
apt -y install libjasper1 && \
apt-get -y install \
libtiff-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libdc1394-22-dev \
libxine2-dev \
libv4l-dev \
vim
RUN cd /usr/include/linux && \
ln -s -f ../libv4l1-videodev.h videodev.h && \
cd $cwd
RUN apt-get install -y \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgtk2.0-dev \
libtbb-dev \
qt5-default \
libatlas-base-dev \
libfaac-dev \
libmp3lame-dev \
libtheora-dev \
libvorbis-dev \
libxvidcore-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
libavresample-dev \
x264 \
v4l-utils \
libprotobuf-dev \
protobuf-compiler \
libgoogle-glog-dev \
libgflags-dev \
libgphoto2-dev \
libeigen3-dev \
libhdf5-dev \
doxygen
USER $NB_UID
RUN $CONDA_DIR/bin/pip install nbgitpuller && \
conda install -y xeus-cling notebook -c QuantStack -c conda-forge && \
conda create -y -f -n OpenCV-"$cvVersion"-py2 python=2.7 anaconda && \
conda install -y -n OpenCV-"$cvVersion"-py2 numpy scipy matplotlib scikit-image scikit-learn ipython ipykernel && \
conda create -y -f -n OpenCV-"$cvVersion"-py3 python=3.6 anaconda && \
conda install -y -n OpenCV-"$cvVersion"-py3 numpy scipy matplotlib scikit-image scikit-learn ipython ipykernel
USER root
#RUN conda install -y xeus-cling notebook -c QuantStack -c conda-forge
RUN /bin/bash -c "source $CONDA_DIR/bin/activate OpenCV-\"$cvVersion\"-py2 && \
python -m ipykernel install --name OpenCV-\"$cvVersion\"-py2 && \
source $CONDA_DIR/bin/activate OpenCV-\"$cvVersion\"-py3 && \
python -m ipykernel install --name OpenCV-\"$cvVersion\"-py3 && \
jupyter serverextension enable --py nbgitpuller --sys-prefix"
#RUN chown $NB_UID $CONDA_DIR
USER $NB_UID
RUN fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER
USER root
WORKDIR $cwd
RUN git clone https://github.com/opencv/opencv.git && \
cd opencv && \
git checkout $cvVersion && \
cd ..
RUN git clone https://github.com/opencv/opencv_contrib.git && \
cd opencv_contrib && \
git checkout $cvVersion && \
cd ..
WORKDIR $CONDA_DIR/envs/
RUN mkdir OpenCV-"$cvVersion"-py2/opencv_include && \
cp -r OpenCV-"$cvVersion"-py2/include/* OpenCV-"$cvVersion"-py2/opencv_include && \
cp -r OpenCV-"$cvVersion"-py2/opencv_include/python2.7/* OpenCV-"$cvVersion"-py2/opencv_include && \
mkdir OpenCV-"$cvVersion"-py3/opencv_include && \
cp -r OpenCV-"$cvVersion"-py3/include/* OpenCV-"$cvVersion"-py3/opencv_include && \
cp -r OpenCV-"$cvVersion"-py3/opencv_include/python3.6m/* OpenCV-"$cvVersion"-py3/opencv_include
WORKDIR $cwd
RUN cd opencv && \
mkdir build && \
cd build && \
cmake -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DINSTALL_C_EXAMPLES=ON \
-DWITH_TBB=ON \
-DWITH_V4L=ON \
-DWITH_QT=ON \
-DWITH_OPENGL=ON \
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-DPYTHON2_EXECUTABLE=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py2/bin/python \
-DPYTHON2_INCLUDE_DIR=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py2/opencv_include \
-DPYTHON2_LIBRARY=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py2/lib/libpython2.7.so \
-DPYTHON2_NUMPY_INCLUDE_DIRS=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py2/lib/python2.7/site-packages/numpy/core/include \
-DPYTHON2_PACKAGES=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py2/lib/python2.7/site-packages \
-DPYTHON3_EXECUTABLE=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py3/bin/python \
-DPYTHON3_INCLUDE_DIR=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py3/opencv_include \
-DPYTHON3_LIBRARY=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py3/lib/libpython3.6m.so \
-DPYTHON3_NUMPY_INCLUDE_DIRS=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py3/lib/python3.6/site-packages/numpy/core/include \
-DPYTHON3_PACKAGES_PATH=$CONDA_DIR/envs/OpenCV-"$cvVersion"-py3/lib/python3.6/site-packages .. && \
make -j4 && make install && \
cd ..
RUN /bin/sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
RUN ldconfig
RUN /bin/sh -c 'py2binPath=$(find /usr/local/lib/ -type f -name "cv2.so") && \
py3binPath=$(find /usr/local/lib/ -type f -name "cv2.cpython*.so") && \
cd /opt/conda/envs/OpenCV-$cvVersion-py2/lib/python2.7/site-packages && \
ln -f -s $py2binPath cv2.so && \
cd /opt/conda/envs/OpenCV-$cvVersion-py3/lib/python3.6/site-packages && \
ln -f -s $py3binPath cv2.so'
WORKDIR $cwd
# Install dlib
RUN wget http://dlib.net/files/dlib-19.15.tar.bz2 && \
tar xvf dlib-19.15.tar.bz2 && \
cd dlib-19.15 && \
mkdir build && \
cd build && \
cmake .. && \
make && \
#cmake --build . --config Release && \
make install && \
ldconfig && \
cd ..
WORKDIR $cwd/dlib-19.15
RUN /bin/bash -c "source $CONDA_DIR/bin/activate OpenCV-\"$cvVersion\"-py2 && \
python $cwd/dlib-19.15/setup.py install && \
rm -rf $cwd/dlib-19.15/dist && \
rm -rf $cwd/dlib-19.15/tools/python/build && \
#rm $cwd/dlib-19.15/python_examples/dlib.so && \
source $CONDA_DIR/bin/activate OpenCV-\"$cvVersion\"-py3 && \
python $cwd/dlib-19.15/setup.py install && \
rm -rf $cwd/dlib-19.15/dist && \
rm -rf $cwd/dlib-19.15/tools/python/build"
WORKDIR $cwd
ENV PATH $CONDA_DIR/bin:$PATH
USER root
#RUN chown $NB_USER $CONDA_DIR
RUN chown $NB_USER:$NB_GID $CONDA_DIR
RUN rm /opt/conda/envs/OpenCV-"$cvVersion"-py3/lib/libfontconfig.so.1 && \
rm /opt/conda/envs/OpenCV-"$cvVersion"-py2/lib/libfontconfig.so.1
USER $NB_UID
WORKDIR $HOME
ENV DEBIAN_FRONTEND teletype