Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile-debian based setup failed with libgtk-x11-2.0.so.0 Error #101

Open
xyboox opened this issue Jun 13, 2023 · 0 comments
Open

Dockerfile-debian based setup failed with libgtk-x11-2.0.so.0 Error #101

xyboox opened this issue Jun 13, 2023 · 0 comments

Comments

@xyboox
Copy link

xyboox commented Jun 13, 2023

Below is my Dockerfile derived from Dockerfile-debian. I just added ffmpeg support for opencv. Build is errorless, but then on run, I get this error ( please check below ).

Dockerfile:

FROM node:18 As build

RUN apt update && apt -y upgrade && apt -y install yasm nasm \
                build-essential automake autoconf \
                libtool pkg-config libcurl4-openssl-dev \
                intltool libxml2-dev libgtk2.0-dev \
                libnotify-dev libglib2.0-dev libevent-dev \
                checkinstall
RUN wget https://www.ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
RUN tar jxvf ffmpeg-snapshot.tar.bz2
WORKDIR /ffmpeg
RUN ls -liah
RUN ./configure --prefix=/usr 

RUN cat RELEASE
RUN checkinstall

RUN dpkg --install ffmpeg_*.deb

RUN apt -y install build-essential libavformat-dev libavcodec-dev libswscale-dev libavresample-dev cmake

RUN ffmpeg -version

ENV OPENCV_BUILD_ROOT=/usr/src/opencv
ENV OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION=4.6.0

RUN npm install -g rimraf
RUN npm install -g @u4/opencv4nodejs

RUN rimraf /usr/local/lib/node_modules/**/*.{md,map,txt}
RUN rimraf /usr/local/lib/node_modules/{@eslint}
RUN rimraf /usr/local/lib/node_modules/**/{LICENSE,.github,.npmignore,LICENSE.txt,.travis.yml,.eslintrc,sponsors}
RUN rimraf /usr/local/lib/node_modules/*/test
RUN find /usr/local/lib/node_modules/ -type f -empty -print -delete
RUN find /usr/local/lib/node_modules/ -type d -empty -print -delete
RUN rimraf /usr/src/opencv/opencv-*/build/{doc,3rdparty,*.txt,*.cmake,*.tmp,tmp,downloads,opencv_python_tests.cfg}
RUN rimraf /usr/src/opencv/opencv-*/**/{cmake,*.txt,*.cmake,*.make,*.tmp,*.o,*.md,*.cpp,Makefile,CMakeFiles,*.sh}
RUN rimraf /usr/src/opencv/opencv-*/build/modules/.firstpass/
RUN rimraf /usr/src/opencv/opencv-*/build/share/opencv4/testdata
RUN rimraf /usr/src/opencv/opencv-*/build/share/
RUN find /usr/src/opencv/ -type f -empty -print -delete
RUN find /usr/src/opencv/ -type d -empty -print -delete

FROM node:18 As production

ENV OPENCV_BUILD_ROOT=/usr/src/opencv
ENV OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION=4.6.0

WORKDIR /usr/src/app

COPY --from=build /usr/src/opencv /usr/src/opencv
COPY --from=build /usr/local/lib/node_modules/@u4 /usr/local/lib/node_modules/@u4

RUN mkdir -p /var/app
WORKDIR /var/app

RUN npm install pm2 -g
RUN pm2 ls

COPY package.json ./
COPY ./bin .

RUN npm remove @u4/opencv4nodejs
RUN npm install
RUN npm link @u4/opencv4nodejs

EXPOSE 12002

ENTRYPOINT /var/app/docker-entrypoint-bwh.sh

Node js code:

const cv2 = require('@u4/opencv4nodejs');
vCap = new cv2.VideoCapture('video.mp4');

vCap.set(cv2.CAP_PROP_FRAME_WIDTH, 512);
vCap.set(cv2.CAP_PROP_FRAME_HEIGHT, 512);

setInterval(() => {
	const frame = vCap.read();
	const image = cv2.imencode('.jpg', frame).toString('base64');
	io.emit('image', image);
}, 1000 / FPS);

Runtime ERROR:

/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/cvloader.js:62
            throw err;
            ^

Error: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
    at Module._extensions..node (node:internal/modules/cjs/loader:1338:18)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at getOpenCV (/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/cvloader.js:54:23)
    at loadOpenCV (/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js:6:48)
    at Object.<anonymous> (/usr/local/lib/node_modules/@u4/opencv4nodejs/lib/opencv4nodejs.js:21:12)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) {
  code: 'ERR_DLOPEN_FAILED'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant