Dockerfile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. FROM alpine AS opencv-builder
  2. ARG OPENCV_VERSION
  3. RUN apk --no-cache add python make g++ cmake linux-headers
  4. RUN mkdir opencv && \
  5. cd opencv && \
  6. wget https://github.com/Itseez/opencv/archive/${OPENCV_VERSION}.zip --no-check-certificate -O opencv-${OPENCV_VERSION}.zip && \
  7. unzip opencv-${OPENCV_VERSION}.zip && \
  8. mkdir opencv-${OPENCV_VERSION}/build && \
  9. cd opencv-${OPENCV_VERSION}/build && \
  10. cmake_flags="-D CMAKE_BUILD_TYPE=RELEASE \
  11. -D BUILD_EXAMPLES=OFF \
  12. -D BUILD_DOCS=OFF \
  13. -D BUILD_TESTS=OFF \
  14. -D BUILD_PERF_TESTS=OFF \
  15. -D BUILD_JAVA=OFF \
  16. -D BUILD_opencv_apps=OFF \
  17. -D BUILD_opencv_aruco=OFF \
  18. -D BUILD_opencv_bgsegm=OFF \
  19. -D BUILD_opencv_bioinspired=OFF \
  20. -D BUILD_opencv_ccalib=OFF \
  21. -D BUILD_opencv_datasets=OFF \
  22. -D BUILD_opencv_dnn_objdetect=OFF \
  23. -D BUILD_opencv_dpm=OFF \
  24. -D BUILD_opencv_fuzzy=OFF \
  25. -D BUILD_opencv_hfs=OFF \
  26. -D BUILD_opencv_java_bindings_generator=OFF \
  27. -D BUILD_opencv_js=OFF \
  28. -D BUILD_opencv_img_hash=OFF \
  29. -D BUILD_opencv_line_descriptor=OFF \
  30. -D BUILD_opencv_optflow=OFF \
  31. -D BUILD_opencv_phase_unwrapping=OFF \
  32. -D BUILD_opencv_python3=OFF \
  33. -D BUILD_opencv_python_bindings_generator=OFF \
  34. -D BUILD_opencv_reg=OFF \
  35. -D BUILD_opencv_rgbd=OFF \
  36. -D BUILD_opencv_saliency=OFF \
  37. -D BUILD_opencv_shape=OFF \
  38. -D BUILD_opencv_stereo=OFF \
  39. -D BUILD_opencv_stitching=OFF \
  40. -D BUILD_opencv_structured_light=OFF \
  41. -D BUILD_opencv_superres=OFF \
  42. -D BUILD_opencv_surface_matching=OFF \
  43. -D BUILD_opencv_ts=OFF \
  44. -D BUILD_opencv_xobjdetect=OFF \
  45. -D BUILD_opencv_xphoto=OFF" && \
  46. echo $cmake_flags && \
  47. cmake $cmake_flags .. && \
  48. make -j $(nproc) && \
  49. make install
  50. FROM node:10-alpine AS builder
  51. ARG OPENCV_VERSION
  52. ENV OPENCV4NODEJS_DISABLE_AUTOBUILD=1
  53. RUN apk --no-cache add python make g++
  54. COPY --from=opencv-builder /opencv/opencv-${OPENCV_VERSION}/build/lib/libopencv* /usr/local/lib/
  55. COPY --from=opencv-builder /usr/local/include/opencv2 /usr/local/include/opencv2
  56. COPY --from=opencv-builder /usr/local/share/OpenCV /usr/local/share/OpenCV
  57. COPY ./bot/package.json ./
  58. RUN npm install
  59. WORKDIR /db/
  60. COPY ./db/package.json .
  61. RUN npm install
  62. FROM node:10-alpine
  63. ARG OPENCV_VERSION
  64. WORKDIR /app
  65. RUN apk --no-cache add make
  66. COPY --from=builder node_modules bot/node_modules
  67. COPY --from=builder /db/node_modules db/node_modules
  68. COPY --from=opencv-builder /opencv/opencv-${OPENCV_VERSION}/build/lib/libopencv* /usr/local/lib/
  69. COPY --from=opencv-builder /usr/local/include/opencv2 /usr/local/include/opencv2
  70. COPY --from=opencv-builder /usr/local/share/OpenCV /usr/local/share/OpenCV
  71. COPY ./bot bot
  72. COPY ./db db
  73. COPY ./Makefile Makefile
  74. RUN make build_bot
  75. WORKDIR /app/bot
  76. EXPOSE 3000
  77. CMD npm run start