'install opencv in existing dockerfile in gitlab
enter image description herei added below code to my docker file and the job run successfully but , in modules java in not available.
first FROM python:3.9
LABEL mantainer="Baher Elnaggar [email protected]"
WORKDIR /opt/build
ENV OPENCV_VERSION="4.5.1"
RUN apt-get -qq update
&& apt-get -qq install -y --no-install-recommends
build-essential
cmake
git
wget
unzip
yasm
pkg-config
libswscale-dev
libtbb2
libtbb-dev
libjpeg-dev
libpng-dev
libtiff-dev
libopenjp2-7-dev
libavformat-dev
libpq-dev
&& pip install numpy
&& wget -q https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip -O opencv.zip \
&& unzip -qq opencv.zip -d /opt \
&& rm -rf opencv.zip \
&& cmake \
-D BUILD_TIFF=ON \
-D BUILD_opencv_java=OFF \
-D WITH_CUDA=OFF \
-D WITH_OPENGL=ON \
-D WITH_OPENCL=ON \
-D WITH_IPP=ON \
-D WITH_TBB=ON \
-D WITH_EIGEN=ON \
-D WITH_V4L=ON \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$(python3.9 -c "import sys; print(sys.prefix)") \
-D PYTHON_EXECUTABLE=$(which python3.9) \
-D PYTHON_INCLUDE_DIR=$(python3.9 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON_PACKAGES_PATH=$(python3.9 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
/opt/opencv-${OPENCV_VERSION} \
&& make -j$(nproc) \
&& make install \
&& rm -rf /opt/build/* \
&& rm -rf /opt/opencv-${OPENCV_VERSION} \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get -qq autoremove \
&& apt-get -qq clean
Then i added Java_home
RUN apt-get update &&
apt-get install -y openjdk-8-jdk &&
apt-get install -y ant &&
apt-get clean &&
rm -rf /var/lib/apt/lists/ &&
rm -rf /var/cache/oracle-jdk8-installer;
enter code here
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/ RUN export JAVA_HOME
**But still job run successfully but my requirements is not satisfied . Can any one tell me to install opencv with java_home 8
My requirement is to add opencv layer to my docker image . i need to install OPENCV , i am added this code in my existing dockerfile in gitlab.**
but Old build getting deployed when you run the pipeline
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
