-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalpine.Dockerfile
99 lines (95 loc) · 3.94 KB
/
alpine.Dockerfile
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
################################################################################
## Dockerfile to build minimal OpenCV img with Python3.7 and Video support ##
################################################################################
FROM alpine:3.10
ENV LANG=C.UTF-8
ARG OPENCV_VERSION=4.4.0
RUN apk add --update --no-cache \
# Build dependencies
build-base clang clang-dev cmake pkgconf wget openblas openblas-dev \
linux-headers \
# Edge tpu
libedgetpu1-std python3-edgetpu \
# Image IO packages
libjpeg-turbo libjpeg-turbo-dev \
libpng libpng-dev \
libwebp libwebp-dev \
tiff tiff-dev \
jasper-libs jasper-dev \
openexr openexr-dev \
# Video depepndencies
ffmpeg-libs ffmpeg-dev \
libavc1394 libavc1394-dev \
gstreamer gstreamer-dev \
gst-plugins-base gst-plugins-base-dev \
libgphoto2 libgphoto2-dev && \
apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
--update --no-cache libtbb libtbb-dev && \
# Python dependencies
apk add --no-cache python3=3.7.5-r1 python3-dev=3.7.5-r1 && \
#apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
# --update --no-cache py-numpy py-numpy-dev && \
# Update also musl to avoid an Alpine bug
apk upgrade --repository http://dl-cdn.alpinelinux.org/alpine/edge/main musl && \
# Make Python3 as default
ln -vfs /usr/bin/python3 /usr/local/bin/python && \
ln -vfs /usr/bin/pip3 /usr/local/bin/pip && \
# Fix libpng path
ln -vfs /usr/include/libpng16 /usr/include/libpng && \
ln -vfs /usr/include/locale.h /usr/include/xlocale.h && \
pip3 install -v --no-cache-dir --upgrade pip && \
pip3 install -v --no-cache-dir numpy && \
# Download OpenCV source
cd /tmp && \
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.tar.gz && \
tar -xvzf $OPENCV_VERSION.tar.gz && \
rm -vrf $OPENCV_VERSION.tar.gz && \
wget -0 $OPENCV_VERSION_contrib.tar.gz https://github.com/opencv/opencv-contrib/archive/$OPENCV_VERSION.tar.gz && \
tar -xvzf $OPENCV_VERSION_contrib.tar.gz && \
rm -vrf $OPENCV_VERSION_contrib.tar.gz && \
# Configure
mkdir -vp /tmp/opencv-$OPENCV_VERSION/build && \
cd /tmp/opencv-$OPENCV_VERSION/build && \
cmake \
# Compiler params
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_C_COMPILER=/usr/bin/clang \
-D CMAKE_CXX_COMPILER=/usr/bin/clang++ \
-D CMAKE_INSTALL_PREFIX=/usr \
# No examples
-D INSTALL_PYTHON_EXAMPLES=NO \
-D INSTALL_C_EXAMPLES=NO \
-D OPENCV_EXTRA_MODULES_PATH=/tmp/opencv_contrib/modules \
# Support
-D WITH_IPP=NO \
-D WITH_1394=NO \
-D WITH_LIBV4L=NO \
-D WITH_V4l=YES \
-D WITH_TBB=YES \
-D WITH_FFMPEG=YES \
-D WITH_GPHOTO2=YES \
-D WITH_GSTREAMER=YES \
# NO doc test and other bindings
-D BUILD_DOCS=NO \
-D BUILD_TESTS=NO \
-D BUILD_PERF_TESTS=NO \
-D BUILD_EXAMPLES=NO \
-D BUILD_opencv_java=NO \
-D BUILD_opencv_python2=NO \
-D BUILD_ANDROID_EXAMPLES=NO \
# Build Python3 bindings only
-D PYTHON3_LIBRARY=`find /usr -name libpython3.so` \
-D PYTHON_EXECUTABLE=`which python3` \
-D PYTHON3_EXECUTABLE=`which python3` \
-D BUILD_opencv_python3=YES .. && \
# Build
make -j`grep -c '^processor' /proc/cpuinfo` && \
make install && \
# Cleanup
cd / && rm -vrf /tmp/opencv-$OPENCV_VERSION && \
apk del --purge build-base clang clang-dev cmake pkgconf wget openblas-dev \
openexr-dev gstreamer-dev gst-plugins-base-dev libgphoto2-dev \
libtbb-dev libjpeg-turbo-dev libpng-dev tiff-dev jasper-dev \
ffmpeg-dev libavc1394-dev python3-dev && \
rm -vrf /var/cache/apk/*
RUN pip3 install https://dl.google.com/coral/python/tflite_runtime-2.1.0.post1-cp37-cp37m-linux_armv7l.whl