-
Notifications
You must be signed in to change notification settings - Fork 875
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5549f1
commit 2cc89e5
Showing
5 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build-ubuntu-opencv | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ubuntu: | ||
description: 'ubuntu version (ex: 22.04)' | ||
required: true | ||
default: '22.04' | ||
opencv: | ||
description: 'opencv version (ex: 4.10.0)' | ||
required: true | ||
default: '4.10.0' | ||
|
||
jobs: | ||
build-arm64: | ||
runs-on: [self-hosted, linux, ARM64] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Build | ||
run: UBUNTU_VERSION=${{ github.event.inputs.ubuntu }} OPENCV_VERSION=${{ github.event.inputs.opencv }} ./github/build-ubuntu-arm64.sh | ||
build-amd64: | ||
runs-on: [self-hosted, linux, X64] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Build | ||
run: UBUNTU_VERSION=${{ github.event.inputs.ubuntu }} OPENCV_VERSION=${{ github.event.inputs.opencv }} ./github/build-ubuntu-amd64.sh | ||
build-manifest: | ||
runs-on: [self-hosted, linux, X64] | ||
needs: [build-arm64, build-amd64] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Build manifest | ||
run: UBUNTU_VERSION=${{ github.event.inputs.ubuntu }} OPENCV_VERSION=${{ github.event.inputs.opencv }} ./github/build-ubuntu-manifest.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# OpenCV 4 prebuilt multiarchitecture image | ||
# | ||
# To build release: | ||
# docker buildx build -f Dockerfile.opencv -t ghcr.io/hybridgroup/opencv:4.10.0 -t ghcr.io/hybridgroup/opencv:latest --platform=linux/arm64,linux/amd64 --push . | ||
# | ||
# To build prerelease: | ||
# docker buildx build --build-arg OPENCV_VERSION="4.x" --build-arg OPENCV_FILE="https://github.com/opencv/opencv/archive/refs/heads/4.x.zip" --build-arg OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/refs/heads/4.x.zip" -f Dockerfile.opencv -t ghcr.io/hybridgroup/opencv:4.10.0-dev --platform=linux/arm64,linux/amd64 --push . | ||
|
||
|
||
################### | ||
# amd64 build stage | ||
################### | ||
|
||
FROM --platform=linux/amd64 ubuntu:22.04 AS opencv-base-amd64 | ||
LABEL maintainer="hybridgroup" | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
git build-essential cmake pkg-config unzip libgtk2.0-dev \ | ||
curl ca-certificates libcurl4-openssl-dev libssl-dev \ | ||
libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev \ | ||
libjpeg62-turbo-dev libpng-dev libtiff-dev libdc1394-22-dev nasm && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
FROM --platform=linux/amd64 opencv-base-amd64 AS opencv-build-amd64 | ||
|
||
ARG OPENCV_VERSION="4.10.0" | ||
ENV OPENCV_VERSION $OPENCV_VERSION | ||
|
||
ARG OPENCV_FILE="https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip" | ||
ENV OPENCV_FILE $OPENCV_FILE | ||
|
||
ARG OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip" | ||
ENV OPENCV_CONTRIB_FILE $OPENCV_CONTRIB_FILE | ||
|
||
RUN curl -Lo opencv.zip ${OPENCV_FILE} && \ | ||
unzip -q opencv.zip && \ | ||
curl -Lo opencv_contrib.zip ${OPENCV_CONTRIB_FILE} && \ | ||
unzip -q opencv_contrib.zip && \ | ||
rm opencv.zip opencv_contrib.zip | ||
|
||
RUN cd opencv-${OPENCV_VERSION} && \ | ||
mkdir build && cd build && \ | ||
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | ||
-D WITH_IPP=OFF \ | ||
-D WITH_OPENGL=OFF \ | ||
-D WITH_QT=OFF \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/local \ | ||
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \ | ||
-D OPENCV_ENABLE_NONFREE=ON \ | ||
-D WITH_JASPER=OFF \ | ||
-D WITH_TBB=ON \ | ||
-D BUILD_JPEG=ON \ | ||
-D WITH_SIMD=ON \ | ||
-D ENABLE_LIBJPEG_TURBO_SIMD=ON \ | ||
-D BUILD_DOCS=OFF \ | ||
-D BUILD_EXAMPLES=OFF \ | ||
-D BUILD_TESTS=OFF \ | ||
-D BUILD_PERF_TESTS=ON \ | ||
-D BUILD_opencv_java=NO \ | ||
-D BUILD_opencv_python=NO \ | ||
-D BUILD_opencv_python2=NO \ | ||
-D BUILD_opencv_python3=NO \ | ||
-D OPENCV_GENERATE_PKGCONFIG=ON .. && \ | ||
make -j $(nproc --all) && \ | ||
make preinstall && make install && ldconfig && \ | ||
cd / && rm -rf opencv* | ||
|
||
|
||
################### | ||
# amd64 build stage | ||
################### | ||
|
||
FROM --platform=linux/arm64 ubuntu:22.04 AS opencv-base-arm64 | ||
LABEL maintainer="hybridgroup" | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
git build-essential cmake pkg-config unzip libgtk2.0-dev \ | ||
curl ca-certificates libcurl4-openssl-dev libssl-dev \ | ||
libavcodec-dev libavformat-dev libswscale-dev libtbb2 libtbb-dev \ | ||
libjpeg62-turbo-dev libpng-dev libtiff-dev libdc1394-22-dev && \ | ||
apt-get autoremove -y && apt-get autoclean -y | ||
|
||
FROM --platform=linux/arm64 opencv-base-arm64 AS opencv-build-arm64 | ||
|
||
ARG OPENCV_VERSION="4.10.0" | ||
ENV OPENCV_VERSION $OPENCV_VERSION | ||
|
||
ARG OPENCV_FILE="https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip" | ||
ENV OPENCV_FILE $OPENCV_FILE | ||
|
||
ARG OPENCV_CONTRIB_FILE="https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip" | ||
ENV OPENCV_CONTRIB_FILE $OPENCV_CONTRIB_FILE | ||
|
||
RUN curl -Lo opencv.zip ${OPENCV_FILE} && \ | ||
unzip -q opencv.zip && \ | ||
curl -Lo opencv_contrib.zip ${OPENCV_CONTRIB_FILE} && \ | ||
unzip -q opencv_contrib.zip && \ | ||
rm opencv.zip opencv_contrib.zip | ||
|
||
RUN cd opencv-${OPENCV_VERSION} && \ | ||
mkdir build && cd build && \ | ||
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | ||
-D WITH_IPP=OFF \ | ||
-D WITH_OPENGL=OFF \ | ||
-D WITH_QT=OFF \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/local \ | ||
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${OPENCV_VERSION}/modules \ | ||
-D OPENCV_ENABLE_NONFREE=ON \ | ||
-D WITH_JASPER=OFF \ | ||
-D WITH_TBB=ON \ | ||
-D BUILD_JPEG=ON \ | ||
-D WITH_SIMD=ON \ | ||
-D ENABLE_LIBJPEG_TURBO_SIMD=ON \ | ||
-D BUILD_DOCS=OFF \ | ||
-D BUILD_EXAMPLES=OFF \ | ||
-D BUILD_TESTS=OFF \ | ||
-D BUILD_PERF_TESTS=ON \ | ||
-D BUILD_opencv_java=NO \ | ||
-D BUILD_opencv_python=NO \ | ||
-D BUILD_opencv_python2=NO \ | ||
-D BUILD_opencv_python3=NO \ | ||
-D OPENCV_GENERATE_PKGCONFIG=ON .. && \ | ||
make -j $(nproc --all) && \ | ||
make preinstall && make install && ldconfig && \ | ||
cd / && rm -rf opencv* | ||
|
||
ARG TARGETARCH | ||
|
||
################### | ||
# multiarch build stage | ||
################### | ||
|
||
FROM opencv-build-${TARGETARCH} as opencv-final | ||
|
||
CMD ["opencv_version", "-b"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash -xe | ||
|
||
[ -z "${OPENCV_VERSION}" ] && echo "Need to set OPENCV_VERSION" && exit 1 | ||
[ -z "${UBUNTU_VERSION}" ] && echo "Need to set UBUNTU_VERSION" && exit 1 | ||
|
||
# Build deploy docker image | ||
GIT_COMMIT_ID=$(git rev-parse HEAD | cut -c1-7) | ||
IMAGE="774915305292.dkr.ecr.us-west-2.amazonaws.com/ubuntu-with-opencv:ubuntu-${UBUNTU_VERSION}-opencv-${OPENCV_VERSION}-amd64" | ||
AWS_CLI_VERSION=$(aws --version 2>&1 | cut -d " " -f1 | cut -d "/" -f2 | cut -c 1) | ||
|
||
docker buildx build --no-cache --pull \ | ||
--platform linux/amd64 \ | ||
-t "${IMAGE}" \ | ||
--build-arg OPENCV_VERSION=$OPENCV_VERSION \ | ||
-f Dockerfile.umbo.ubuntu . | ||
aws ecr get-login --no-include-email --region us-west-2 | bash | ||
# Push docker images | ||
docker push "${IMAGE}" | ||
docker rmi -f "${IMAGE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash -xe | ||
|
||
[ -z "${OPENCV_VERSION}" ] && echo "Need to set OPENCV_VERSION" && exit 1 | ||
[ -z "${UBUNTU_VERSION}" ] && echo "Need to set UBUNTU_VERSION" && exit 1 | ||
|
||
# Build deploy docker image | ||
GIT_COMMIT_ID=$(git rev-parse HEAD | cut -c1-7) | ||
IMAGE="774915305292.dkr.ecr.us-west-2.amazonaws.com/ubuntu-with-opencv:ubuntu-${UBUNTU_VERSION}-opencv-${OPENCV_VERSION}-arm64" | ||
AWS_CLI_VERSION=$(aws --version 2>&1 | cut -d " " -f1 | cut -d "/" -f2 | cut -c 1) | ||
|
||
docker buildx build --no-cache --pull \ | ||
--platform linux/arm64 \ | ||
-t "${IMAGE}" \ | ||
--build-arg OPENCV_VERSION=$OPENCV_VERSION \ | ||
-f Dockerfile.umbo.ubuntu . | ||
aws ecr get-login --no-include-email --region us-west-2 | bash | ||
# Push docker images | ||
docker push "${IMAGE}" | ||
docker rmi -f "${IMAGE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash -xe | ||
|
||
[ -z "${OPENCV_VERSION}" ] && echo "Need to set OPENCV_VERSION" && exit 1 | ||
[ -z "${UBUNTU_VERSION}" ] && echo "Need to set UBUNTU_VERSION" && exit 1 | ||
|
||
MANIFEST="774915305292.dkr.ecr.us-west-2.amazonaws.com/ubuntu-with-opencv:ubuntu-${UBUNTU_VERSION}-opencv-${OPENCV_VERSION}" | ||
IMAGE_ARM="774915305292.dkr.ecr.us-west-2.amazonaws.com/ubuntu-with-opencv:ubuntu-${UBUNTU_VERSION}-opencv-${OPENCV_VERSION}-arm64" | ||
IMAGE_AMD="774915305292.dkr.ecr.us-west-2.amazonaws.com/ubuntu-with-opencv:ubuntu-${UBUNTU_VERSION}-opencv-${OPENCV_VERSION}-amd64" | ||
aws ecr get-login --no-include-email --region us-west-2 | bash | ||
docker manifest rm "${MANIFEST}" || true | ||
docker manifest create "${MANIFEST}" \ | ||
"${IMAGE_ARM}" \ | ||
"${IMAGE_AMD}" | ||
docker manifest annotate --arch arm64 "${MANIFEST}" \ | ||
"${IMAGE_ARM}" | ||
docker manifest annotate --arch amd64 "${MANIFEST}" \ | ||
"${IMAGE_AMD}" | ||
docker manifest push "${MANIFEST}" |