diff --git a/Dockerfile b/Dockerfile index 9a47f00..ba97df7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,31 @@ FROM python:3.6.3-stretch -RUN apt-get -y update \ - && apt-get -y install autoconf-archive automake g++ libtool pkg-config unzip build-essential cmake \ - libatlas-base-dev gfortran libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev \ - libtiff-dev libv4l-dev libleptonica-dev \ - && pip install numpy==1.13.3 \ - && curl -sSL https://github.com/Itseez/opencv/archive/3.3.0.zip -o opencv3.zip \ +RUN echo "deb http://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list \ + && curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | apt-key add - \ + && apt-get -y update \ + && apt-get -y install autoconf-archive automake g++ libtool pkg-config unzip build-essential cmake \ + libatlas-base-dev gfortran libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev \ + libtiff-dev libv4l-dev libleptonica-dev openjdk-8-jdk openjdk-8-jre-headless ca-certificates-java \ + clang-format-3.8 libcurl4-openssl-dev libtool python-dev python-setuptools python-virtualenv \ + python3-dev python3-setuptools zlib1g-dev bazel\ + && pip install numpy==1.13.3 wheel \ + && update-ca-certificates -f + +# install tensorflow from sources +RUN curl -sSL https://github.com/tensorflow/tensorflow/archive/r1.4.zip -o tensorflow.zip \ + && unzip -q tensorflow.zip && mv /tensorflow-r1.4 /tensorflow && rm tensorflow.zip + && cd tensorflow \ + && tensorflow/tools/ci_build/builds/configured CPU \ + && touch WORKSPACE \ + && echo "startup --batch\nbuild --spawn_strategy=standalone --genrule_strategy=standalone" >>/etc/bazel.bazelrc \ + && bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.2 \ + --output_filter='^//tensorflow' //tensorflow/tools/pip_package:build_pip_package \ + && bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg \ + && pip install --upgrade /tmp/tensorflow_pkg/tensorflow-*.whl \ + && cd / && rm -rf tensorflow + +# install opencv3.3.0 +RUN curl -sSL https://github.com/Itseez/opencv/archive/3.3.0.zip -o opencv3.zip \ && unzip -q opencv3.zip && mv /opencv-3.3.0 /opencv && rm opencv3.zip \ && curl -sSL https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip -o opencv_contrib3.zip \ && unzip -q opencv_contrib3.zip && mv /opencv_contrib-3.3.0 /opencv_contrib && rm opencv_contrib3.zip \ @@ -24,6 +44,7 @@ RUN apt-get -y update \ && cd /opencv/build && make -j$(nproc) && make install && ldconfig \ && rm -rf /opencv /opencv_contrib +# install tesseract4 RUN cd / \ && curl -sSL https://github.com/tesseract-ocr/tesseract/archive/ebbfc3ae8df85c351002000a76900e3086375e7b.zip -o tesseract-ocr.zip \ && unzip tesseract-ocr.zip && rm tesseract-ocr.zip \ @@ -38,8 +59,9 @@ RUN cd / \ && curl -sSL 'https://github.com/tesseract-ocr/tessdata/blob/master/eng.traineddata?raw=true' \ -o /usr/local/share/eng.traineddata +# clean up RUN apt-get -y remove --purge autoconf-archive automake g++ libtool unzip build-essential cmake pkg-config \ - libatlas-base-dev gfortran libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev \ - libjpeg-dev libpng-dev libtiff-dev libv4l-dev \ + libatlas-base-dev gfortran libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev \ + libjpeg-dev libpng-dev libtiff-dev libv4l-dev libcurl4-openssl-dev libtool zlib1g-dev\ && apt-get clean \ && rm -rf /var/lib/apt/lists/*