Skip to content

Instantly share code, notes, and snippets.

@lukin0110
Created March 30, 2017 08:48
Show Gist options
  • Save lukin0110/1edabde432c1d253f2d332b64ece3038 to your computer and use it in GitHub Desktop.
Save lukin0110/1edabde432c1d253f2d332b64ece3038 to your computer and use it in GitHub Desktop.
Docker + Python 3 + OpenCV 3.2
FROM python:3.6.1
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /
# Install some essential build tools
RUN apt-get update \
&& apt-get -y install wget unzip \
build-essential cmake git pkg-config libatlas-base-dev gfortran \
libjasper-dev libgtk2.0-dev libavcodec-dev libavformat-dev \
libswscale-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libv4l-dev \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py
RUN pip3 install numpy
# Install OpenCV 3.2.0
RUN wget https://github.com/Itseez/opencv/archive/3.2.0.zip \
&& unzip 3.2.0.zip \
&& mv opencv-3.2.0 /opencv \
&& mkdir /opencv/release \
&& cd /opencv/release \
&& cmake -DBUILD_TIFF=ON \
-DBUILD_opencv_java=OFF \
-DWITH_CUDA=OFF \
-DENABLE_AVX=ON \
-DWITH_OPENGL=ON \
-DWITH_OPENCL=ON \
-DWITH_IPP=OFF \
-DWITH_TBB=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=ON \
-DWITH_VTK=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DBUILD_opencv_python2=OFF \
-DCMAKE_INSTALL_PREFIX=$(python3.6 -c "import sys; print(sys.prefix)") \
-DPYTHON3_EXECUTABLE=$(which python3.6) \
-DPYTHON3_INCLUDE_DIR=$(python3.6 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON3_PACKAGES_PATH=$(python3.6 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") .. \
&& make -j4 \
&& make install \
&& rm /3.2.0.zip \
&& ldconfig
CMD ["bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment