compile_snowboy_python34.dockerfile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # build last version
  2. # docker build --force-rm=true -t compile-snowboy-python34 -f compile_snowboy_python34.dockerfile .
  3. # build specified version
  4. # docker build --force-rm=true --build-arg SNOWBOY_VERSION=1.1.1 -t compile-snowboy-python34 -f compile_snowboy_python34.dockerfile .
  5. # compile into local /tmp/snowboy
  6. # docker run -it --rm --mount type=bind,source=/tmp/snowboy,target=/data compile-snowboy-python34
  7. FROM ubuntu:trusty
  8. RUN apt-get update
  9. RUN apt-get install -y git make g++ python3-dev libatlas3-base libblas-dev gfortran vim wget libpcre3-dev
  10. # get the last version of swig
  11. RUN wget https://downloads.sourceforge.net/swig/swig-3.0.12.tar.gz && tar xzf swig-3.0.12.tar.gz
  12. RUN cd swig-3.0.12 && \
  13. ./configure --prefix=/usr \
  14. --without-clisp \
  15. --without-maximum-compile-warnings && \
  16. make
  17. RUN cd swig-3.0.12 && \
  18. make install && \
  19. install -v -m755 -d /usr/share/doc/swig-3.0.12 && \
  20. cp -v -R Doc/* /usr/share/doc/swig-3.0.12
  21. # version can be 1.2.0, 1.1.1, 1.1.0, 1.0.4
  22. ARG SNOWBOY_VERSION="1.2.0"
  23. RUN wget https://github.com/Kitt-AI/snowboy/archive/v${SNOWBOY_VERSION}.tar.gz && tar xzf v${SNOWBOY_VERSION}.tar.gz
  24. RUN sed -i "s|python-config|python3-config|g" snowboy-${SNOWBOY_VERSION}/swig/Python/Makefile
  25. RUN sed -i "s|-lf77blas -lcblas -llapack_atlas -latlas|-lquadmath -lgfortran -lblas /usr/lib/libcblas.so.3|g" snowboy-${SNOWBOY_VERSION}/swig/Python/Makefile
  26. RUN cd /snowboy-${SNOWBOY_VERSION}/swig/Python && make
  27. RUN cd /snowboy-${SNOWBOY_VERSION}/swig/Python && python3 -c "import _snowboydetect; print('OK')"
  28. # compiled binary will be placed into data folder
  29. RUN mkdir /data
  30. CMD cp /snowboy-*/swig/Python/*.so /data