|
| 1 | +# Version: 20260102 |
| 2 | +# Image name: quay.io/opencv-ci/opencv-python-manylinux2014-x86-64 |
| 3 | + |
| 4 | +FROM ghcr.io/loong64/manylinux_2_38_loongarch64:latest |
| 5 | + |
| 6 | +ARG CCACHE_VERSION=3.7.9 |
| 7 | +ARG FFMPEG_VERSION=8.0.1 |
| 8 | +ARG FREETYPE_VERSION=2.14.1 |
| 9 | +ARG LIBPNG_VERSION=1.6.53 |
| 10 | +ARG VPX_VERSION=v1.15.2 |
| 11 | +ARG NASM_VERSION=2.15.04 |
| 12 | +ARG OPENSSL_VERSION=1_1_1w |
| 13 | +ARG QT_VERSION=5.15.18 |
| 14 | +ARG YASM_VERSION=1.3.0 |
| 15 | +ARG AOM_VERSION=v3.13.1 |
| 16 | +ARG AVIF_VERSION=v1.3.0 |
| 17 | + |
| 18 | +ENV LD_LIBRARY_PATH /usr/local/lib:$LD_LIBRARY_PATH |
| 19 | + |
| 20 | +# epel-release need for aarch64 to get openblas packages |
| 21 | +RUN yum install zlib-devel curl-devel xcb-util-renderutil-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-wm-devel mesa-libGL-devel libxkbcommon-devel libxkbcommon-x11-devel libXi-devel lapack-devel perl-lib -y && \ |
| 22 | + yum install openblas-devel dejavu-sans-fonts -y && \ |
| 23 | + cp /usr/include/openblas/*.h /usr/include/ && \ |
| 24 | + # cp /usr/include/lapacke/lapacke*.h /usr/include/ && \ |
| 25 | + cp -R /usr/share/fonts/dejavu-sans-fonts /usr/share/fonts/dejavu && \ |
| 26 | + # libpng will be built from source |
| 27 | + yum remove libpng -y |
| 28 | + |
| 29 | +RUN mkdir ~/libpng_sources && \ |
| 30 | + cd ~/libpng_sources && \ |
| 31 | + curl -O -L https://download.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.gz && \ |
| 32 | + tar -xf libpng-${LIBPNG_VERSION}.tar.gz && \ |
| 33 | + cd libpng-${LIBPNG_VERSION} && \ |
| 34 | + ./configure --prefix=/usr/local && \ |
| 35 | + make && \ |
| 36 | + make install && \ |
| 37 | + cd .. && \ |
| 38 | + rm -rf ~/libpng_sources |
| 39 | + |
| 40 | +RUN mkdir ~/freetype_sources && \ |
| 41 | + cd ~/freetype_sources && \ |
| 42 | + curl -O -L https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \ |
| 43 | + tar -xf freetype-${FREETYPE_VERSION}.tar.gz && \ |
| 44 | + cd freetype-${FREETYPE_VERSION} && \ |
| 45 | + ./configure --prefix="/ffmpeg_build" --enable-freetype-config && \ |
| 46 | + make && \ |
| 47 | + make install && \ |
| 48 | + cd .. && \ |
| 49 | + rm -rf ~/freetype_sources |
| 50 | + |
| 51 | +RUN curl -O -L https://download.qt.io/archive/qt/5.15/${QT_VERSION}/single/qt-everywhere-opensource-src-${QT_VERSION}.tar.xz && \ |
| 52 | + tar -xf qt-everywhere-opensource-src-${QT_VERSION}.tar.xz && \ |
| 53 | + cd qt-everywhere-src-${QT_VERSION} && \ |
| 54 | + sed -i 's/defined(__mips__) || /defined(__mips__) || defined(__loongarch__) || /g' qtbase/src/3rdparty/double-conversion/include/double-conversion/utils.h && \ |
| 55 | + export MAKEFLAGS=-j$(nproc) && \ |
| 56 | + ./configure -prefix /opt/Qt${QT_VERSION} -release -opensource -confirm-license -qtnamespace QtOpenCVPython -xcb -xcb-xlib -bundled-xcb-xinput -no-openssl -no-dbus -skip qt3d -skip qtactiveqt -skip qtcanvas3d -skip qtconnectivity -skip qtdatavis3d -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtmultimedia -skip qtpurchasing -skip qtqa -skip qtremoteobjects -skip qtrepotools -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qttranslations -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip xmlpatterns -skip declarative -make libs && \ |
| 57 | + make && \ |
| 58 | + make install && \ |
| 59 | + cd .. && \ |
| 60 | + rm -rf qt-everywhere* |
| 61 | + |
| 62 | +ENV QTDIR /opt/Qt${QT_VERSION} |
| 63 | +ENV PATH "$QTDIR/bin:$PATH" |
| 64 | + |
| 65 | +RUN mkdir ~/openssl_sources && \ |
| 66 | + cd ~/openssl_sources && \ |
| 67 | + curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION}.tar.gz && \ |
| 68 | + tar -xf OpenSSL_${OPENSSL_VERSION}.tar.gz && \ |
| 69 | + cd openssl-OpenSSL_${OPENSSL_VERSION} && \ |
| 70 | + ./config --prefix="/ffmpeg_build" --openssldir="/ffmpeg_build" no-pinshared shared zlib && \ |
| 71 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 72 | + # skip installing documentation |
| 73 | + make install_sw && \ |
| 74 | + cd .. && \ |
| 75 | + rm -rf ~/openssl_build ~/openssl_sources |
| 76 | + |
| 77 | +RUN mkdir ~/nasm_sources && \ |
| 78 | + cd ~/nasm_sources && \ |
| 79 | + curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/${NASM_VERSION}/nasm-${NASM_VERSION}.tar.gz && \ |
| 80 | + tar -xf nasm-${NASM_VERSION}.tar.gz && cd nasm-${NASM_VERSION} && ./autogen.sh && \ |
| 81 | + ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \ |
| 82 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 83 | + make install && \ |
| 84 | + cd .. && \ |
| 85 | + rm -rf ~/nasm_sources |
| 86 | + |
| 87 | +RUN mkdir ~/yasm_sources && \ |
| 88 | + cd ~/yasm_sources && \ |
| 89 | + curl -O -L http://www.tortall.net/projects/yasm/releases/yasm-${YASM_VERSION}.tar.gz && \ |
| 90 | + tar -xf yasm-${YASM_VERSION}.tar.gz && \ |
| 91 | + cd yasm-${YASM_VERSION} && \ |
| 92 | + curl -o config/config.sub -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.sub && \ |
| 93 | + curl -o config/config.guess -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.guess && \ |
| 94 | + ./configure --prefix="/ffmpeg_build" --bindir="$HOME/bin" && \ |
| 95 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 96 | + make install && \ |
| 97 | + cd .. && \ |
| 98 | + rm -rf ~/yasm_sources |
| 99 | + |
| 100 | +RUN mkdir ~/libvpx_sources && \ |
| 101 | + cd ~/libvpx_sources && \ |
| 102 | + git clone --depth 1 -b ${VPX_VERSION} https://chromium.googlesource.com/webm/libvpx.git && \ |
| 103 | + cd libvpx && \ |
| 104 | + curl -L https://github.com/webmproject/libvpx/commit/a7863b9a2f01e5d22919a51c95cbc4a9c10fbb2c.patch | patch -p1 && \ |
| 105 | + curl -L https://github.com/webmproject/libvpx/commit/a604e10afbb2e711e62d8d9ca9c64b368e30b0e2.patch | patch -p1 && \ |
| 106 | + ./configure --prefix="/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm --enable-pic --enable-shared && \ |
| 107 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 108 | + make install && \ |
| 109 | + cd .. && \ |
| 110 | + rm -rf ~/libvpx_sources |
| 111 | + |
| 112 | +RUN mkdir ~/aom_sources && \ |
| 113 | + cd ~/aom_sources && \ |
| 114 | + git clone --depth 1 -b ${AOM_VERSION} https://aomedia.googlesource.com/aom && \ |
| 115 | + mkdir build && cd build && \ |
| 116 | + cmake -DCMAKE_C_COMPILER=$(dirname $(which g++))/gcc -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=ON -DENABLE_TESTS=OFF ../aom/ && \ |
| 117 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 118 | + make install && \ |
| 119 | + cd / && rm -rf ~/aom_sources |
| 120 | + |
| 121 | +RUN mkdir ~/avif_sources && \ |
| 122 | + cd ~/avif_sources && \ |
| 123 | + git clone -b ${AVIF_VERSION} https://github.com/AOMediaCodec/libavif.git && \ |
| 124 | + mkdir build && cd build && \ |
| 125 | + cmake -DCMAKE_INSTALL_PREFIX=/usr -DAVIF_CODEC_AOM=SYSTEM -DAVIF_LIBYUV=LOCAL -DAVIF_BUILD_APPS=OFF ../libavif && \ |
| 126 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 127 | + make install && \ |
| 128 | + cd / && rm -rf ~/avif_sources |
| 129 | + |
| 130 | +RUN mkdir ~/ffmpeg_sources && \ |
| 131 | + cd ~/ffmpeg_sources && \ |
| 132 | + curl -O -L https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \ |
| 133 | + tar -xf ffmpeg-${FFMPEG_VERSION}.tar.gz && \ |
| 134 | + cd ffmpeg-${FFMPEG_VERSION} && \ |
| 135 | + PATH=~/bin:$PATH && \ |
| 136 | + PKG_CONFIG_PATH="/ffmpeg_build/lib/pkgconfig" ./configure --prefix="/ffmpeg_build" --extra-cflags="-I/ffmpeg_build/include" --extra-ldflags="-L/ffmpeg_build/lib" --enable-openssl --enable-libvpx --enable-shared --enable-pic --bindir="$HOME/bin" && \ |
| 137 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 138 | + make install && \ |
| 139 | + echo "/ffmpeg_build/lib/" >> /etc/ld.so.conf && \ |
| 140 | + ldconfig && \ |
| 141 | + rm -rf ~/ffmpeg_sources |
| 142 | + |
| 143 | +RUN curl -O -L https://github.com/ccache/ccache/releases/download/v${CCACHE_VERSION}/ccache-${CCACHE_VERSION}.tar.gz && \ |
| 144 | + tar -xf ccache-${CCACHE_VERSION}.tar.gz && \ |
| 145 | + cd ccache-${CCACHE_VERSION} && \ |
| 146 | + curl -O -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.sub && \ |
| 147 | + curl -O -L https://github.com/cgitmirror/config/raw/refs/heads/master/config.guess && \ |
| 148 | + ./configure && \ |
| 149 | + make -j$(getconf _NPROCESSORS_ONLN) && \ |
| 150 | + make install && \ |
| 151 | + cd .. && \ |
| 152 | + rm -rf ccache-${CCACHE_VERSION}.tar.gz |
| 153 | + |
| 154 | +# GitHub Actions user`s UID is 1001 |
| 155 | +RUN useradd ci -m -s /bin/bash -G users --uid=1001 && \ |
| 156 | + mkdir /io && \ |
| 157 | + chown -R ci:ci /io && \ |
| 158 | + # This needs to find ffmpeg packages from ci user |
| 159 | + chown -R ci:ci /ffmpeg_build && \ |
| 160 | + # This calls in mutlibuild scripts and cannot be run without permissions |
| 161 | + chown -R ci:ci /opt/_internal/pipx/venvs/auditwheel |
| 162 | + |
| 163 | +USER ci |
| 164 | + |
| 165 | +# Git security vulnerability: https://github.blog/2022-04-12-git-security-vulnerability-announced |
| 166 | +RUN git config --global --add safe.directory /io |
| 167 | + |
| 168 | +ENV PIP_EXTRA_INDEX_URL https://gitlab.com/api/v4/projects/65746188/packages/pypi/simple |
| 169 | +ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:/ffmpeg_build/lib/pkgconfig |
| 170 | +ENV LDFLAGS -L/ffmpeg_build/lib |
| 171 | +ENV PATH "$HOME/bin:$PATH" |
0 commit comments