Skip to content

Commit

Permalink
build: Fix intermediate dotnet openCV image
Browse files Browse the repository at this point in the history
The image was built using the wrong version of opencvsharp,
fix this.

Also switch to shallow clone to reduce build time (a bit).

Signed-off-by: Nicolas Belouin <[email protected]>
  • Loading branch information
diconico07 committed May 2, 2023
1 parent fdb735e commit 0087bcb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
27 changes: 13 additions & 14 deletions build/containers/intermediate/Dockerfile.opencvsharp-build
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Makefile's USE_OPENCV_BASE_VERSION.
#

ARG PLATFORM_TAG=3.1-buster-slim
FROM mcr.microsoft.com/dotnet/core/aspnet:${PLATFORM_TAG} AS base
ARG PLATFORM=
FROM mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim${PLATFORM} AS base
WORKDIR /app

# Link the container to the Akri repository
Expand Down Expand Up @@ -104,29 +104,28 @@ RUN cd ${OPENCV_INSTALLATION_DIR}/opencv-${OPENCV_VERSION} && \
-D BUILD_opencv_wechat_qrcode=OFF \
-D WITH_GSTREAMER=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
.. && make -j$(grep -c ^processor /proc/cpuinfo) && \
.. && make -j$(nproc) && \
make install -j8 && \
ldconfig

RUN cd ${OPENCV_INSTALLATION_DIR} && \
git clone https://github.com/shimat/opencvsharp.git opencvsharp && \
cd opencvsharp && \
git fetch --all --tags --prune && git checkout ${OPENCV_SHARP_VERSION} && \
cd src && \
git clone --depth=1 --branch=${OPENCV_SHARP_VERSION} https://github.com/shimat/opencvsharp.git opencvsharp && \
cd opencvsharp/src && \
mkdir build && \
cd build && \
cmake -D CMAKE_INSTALL_PREFIX=${OPENCV_INSTALLATION_DIR} .. && \
make -j$(grep -c ^processor /proc/cpuinfo) && \
make -j$(nproc) && \
make install && \
ldconfig && \
cp OpenCvSharpExtern/libOpenCvSharpExtern.so /usr/lib

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-dotnet-env
FROM mcr.microsoft.com/dotnet/sdk:3.1-buster${PLATFORM} AS build-dotnet-env

ENV OPENCV_SHARP_VERSION="4.5.3.20210821"

WORKDIR /
COPY --from=base /usr/lib/libOpenCvSharpExtern.so ./
RUN git clone https://github.com/shimat/opencvsharp.git && \
cd opencvsharp && \
git fetch --all --tags --prune && git checkout ${OPENCV_SHARP_VERSION}
RUN git clone --depth=1 --branch=${OPENCV_SHARP_VERSION} https://github.com/shimat/opencvsharp.git

# Install Build the C# part of OpenCvSharp
RUN cd /opencvsharp/src/OpenCvSharp && \
Expand All @@ -141,11 +140,11 @@ RUN mkdir /opencvsharp/build && \
cp /opencvsharp/src/OpenCvSharp.Extensions/bin/Release/netstandard2.0/* .

# Copy over OpenCvSharp binaries and OpenCvSharpExtern shared library
FROM mcr.microsoft.com/dotnet/core/aspnet:${PLATFORM_TAG}
FROM mcr.microsoft.com/dotnet/aspnet:3.1-buster-slim${PLATFORM}
WORKDIR /app
COPY --from=build-dotnet-env /opencvsharp/build ./
COPY --from=build-dotnet-env /libOpenCvSharpExtern.so /usr/lib
# Install OpenCVSharpEntern dependencies
# Install OpenCVSharpExtern dependencies
RUN apt-get update && apt-get -y install --no-install-recommends \
libgtk2.0-dev \
libavcodec-dev \
Expand Down
6 changes: 3 additions & 3 deletions build/intermediate-containers.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ opencv-base: opencv-base-build opencv-base-docker-per-arch
opencv-base-build: opencv-base-build-amd64 opencv-base-build-arm32 opencv-base-build-arm64
opencv-base-build-amd64:
ifeq (1, ${BUILD_AMD64})
docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(AMD64_SUFFIX) --build-arg PLATFORM_TAG=3.1-buster-slim
docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(AMD64_SUFFIX) --build-arg PLATFORM=
endif
opencv-base-build-arm32:
ifeq (1, ${BUILD_ARM32})
docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM32V7_SUFFIX) --build-arg PLATFORM_TAG=3.1-buster-slim-$(ARM32V7_SUFFIX)
docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM32V7_SUFFIX) --build-arg PLATFORM=-$(ARM32V7_SUFFIX)
endif
opencv-base-build-arm64:
ifeq (1, ${BUILD_ARM64})
docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM64V8_SUFFIX) --build-arg PLATFORM_TAG=3.1-buster-slim-$(ARM64V8_SUFFIX)
docker build $(CACHE_OPTION) -f $(INTERMEDIATE_DOCKERFILE_DIR)/Dockerfile.opencvsharp-build . -t $(PREFIX)/opencvsharp-build:$(BUILD_OPENCV_BASE_VERSION)-$(ARM64V8_SUFFIX) --build-arg PLATFORM=-$(ARM64V8_SUFFIX)
endif
opencv-base-docker-per-arch: opencv-base-docker-per-arch-amd64 opencv-base-docker-per-arch-arm32 opencv-base-docker-per-arch-arm64
opencv-base-docker-per-arch-amd64:
Expand Down

0 comments on commit 0087bcb

Please sign in to comment.