Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jimexist committed Feb 2, 2024
1 parent 9d01b98 commit f1368a2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.github/
target/
70 changes: 70 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
FROM rust:1.75-slim as builder

ENV OPEN_CV_VERSION="4.9.0"

RUN apt-get update && apt-get install -y \
build-essential \
clang \
libclang-dev \
libssl-dev \
wget \
zip \
cmake

WORKDIR /usr/src/opencv

RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/refs/tags/${OPEN_CV_VERSION}.zip && \
unzip opencv.zip && \
rm opencv.zip

RUN wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/refs/tags/${OPEN_CV_VERSION}.zip && \
unzip opencv_contrib.zip && \
rm opencv_contrib.zip

WORKDIR /usr/src/opencv/build

RUN cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=NO \
-DCMAKE_INSTALL_PREFIX=/opt/opencv \
-DBUILD_DOCS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DWITH_PNG=OFF \
-DWITH_JPEG=OFF \
-DWITH_TIFF=OFF \
-DWITH_WEBP=OFF \
-DWITH_OPENJPEG=OFF \
-DWITH_JASPER=OFF \
-DWITH_OPENEXR=OFF \
-DWITH_V4L=OFF \
-DWITH_CAROTENE=OFF \
-DBUILD_opencv_java=OFF \
-DBUILD_opencv_python=OFF \
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-${OPEN_CV_VERSION}/modules \
../opencv-${OPEN_CV_VERSION}

RUN cmake --build . --target install --config Release --parallel 8

RUN cmake --install . --prefix /opt/opencv

WORKDIR /usr/src/surya

COPY . .

RUN ln -s /usr/lib/llvm-15/lib/libclang.so.1 "/usr/lib/$(uname -m)-linux-gnu/libclang.so"

RUN OPENCV_LINK_LIBS="opencv_imgcodecs,opencv_imgproc,opencv_core" \
OPENCV_LINK_PATHS="/opt/opencv/lib,/opt/opencv/lib/opencv4/3rdparty,/usr/lib/$(uname -m)-linux-gnu" \
OPENCV_INCLUDE_PATHS="/opt/opencv/include,/opt/opencv/include/opencv4" \
OPENSSL_LIB_DIR="/usr/lib/$(uname -m)-linux-gnu" \
OPENSSL_INCLUDE_DIR="/usr/include/openssl" \
cargo install --path . --features "cli"

FROM debian:bookworm-slim

WORKDIR /usr/local/bin

COPY --from=builder /usr/local/cargo/bin/surya /usr/local/bin/surya

ENTRYPOINT ["surya"]

0 comments on commit f1368a2

Please sign in to comment.