Skip to content

Commit 3fedfa5

Browse files
authored
Milvus 2.5.3 Script/Patch/Dockerfile with currency (#5336)
1 parent 456239e commit 3fedfa5

File tree

4 files changed

+665
-0
lines changed

4 files changed

+665
-0
lines changed

m/milvus/build_info.json

+4
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@
1313
"v2.4.11": {
1414
"dir": "2.4.11_ubi_9",
1515
"build_script": "milvus-v2.4.11-ubi9.3.sh"
16+
},
17+
"v2.5.3": {
18+
"dir": "2.5.3_ubi_9",
19+
"build_script": "milvus-v2.5.3-ubi9.3.sh"
1620
}
1721
}

m/milvus/dockerfiles/Dockerfile

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
FROM registry.access.redhat.com/ubi9/ubi:9.3 AS build
2+
3+
ARG APPLYMCPU=0
4+
5+
ENV MILVUS_VERSION=v2.5.3
6+
ENV MILVUS_PACKAGE_NAME=milvus
7+
ENV MILVUS_PACKAGE_URL=https://github.com/milvus-io/${MILVUS_PACKAGE_NAME}.git
8+
ENV CMAKE_VERSION=3.30.5
9+
ENV GO_VERSION=1.22.6
10+
11+
ENV PATCH_FILE=https://raw.githubusercontent.com/ppc64le/build-scripts/master/m/milvus/milvus-${MILVUS_VERSION}.patch
12+
ENV PATH=${HOME}/go/bin:/usr/local/go/bin:/usr/local/cmake/bin:${PATH}
13+
ENV VCPKG_FORCE_SYSTEM_BINARIES=1
14+
15+
#Install required repos
16+
RUN yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/CRB/ppc64le/os && \
17+
yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream//ppc64le/os && \
18+
yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os && \
19+
rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official && \
20+
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
21+
22+
#Install dependencies
23+
RUN yum install -y --allowerasing make wget git sudo curl zip unzip tar diffutils pkg-config python3-devel perl-IPC-Cmd perl-Digest-SHA perl-FindBin perl-File-Compare openssl-devel scl-utils openblas-devel rust cargo gcc gcc-c++ libstdc++-static which libaio libuuid-devel ncurses-devel ccache libtool m4 autoconf automake ninja-build zlib-devel libffi-devel gfortran yum-utils patchelf hdf5-devel sqlite-devel bzip2-devel xz-devel perl-open.noarch && \
24+
pip3 install conan==1.64.1 setuptools==59.5.0
25+
26+
#Install cmake
27+
WORKDIR /tmp
28+
RUN wget -c https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \
29+
tar -zxvf cmake-${CMAKE_VERSION}.tar.gz && \
30+
rm -rf cmake-${CMAKE_VERSION}.tar.gz && \
31+
cd cmake-${CMAKE_VERSION} && \
32+
./bootstrap --prefix=/usr/local/cmake --parallel=2 -- -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON && \
33+
make install -j$(nproc) && \
34+
cmake --version
35+
36+
#Install Golang
37+
WORKDIR /tmp
38+
RUN wget https://go.dev/dl/go${GO_VERSION}.linux-ppc64le.tar.gz && \
39+
rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-ppc64le.tar.gz && \
40+
rm -rf go${GO_VERSION}.linux-ppc64le.tar.gz && \
41+
go version
42+
43+
#Get milvus source and apply patch
44+
WORKDIR /tmp
45+
COPY milvus-${MILVUS_VERSION}.patch .
46+
#RUN wget ${PATCH_FILE} && \
47+
RUN git clone -b ${MILVUS_VERSION} ${MILVUS_PACKAGE_URL} && \
48+
cd ${MILVUS_PACKAGE_NAME} && \
49+
git apply ../milvus-${MILVUS_VERSION}.patch && \
50+
if [[ "${APPLYMCPU}" -eq 1 ]]; then sed -i "53d" ./internal/core/CMakeLists.txt; sed -i '53i set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -mcpu=power10")' ./internal/core/CMakeLists.txt; fi
51+
52+
#Build
53+
WORKDIR /tmp/${MILVUS_PACKAGE_NAME}
54+
RUN pushd /usr/local/cmake && \
55+
touch /usr/local/cmake/conanfile.py && \
56+
printf 'from conans import ConanFile, tools \n\
57+
class CmakeConan(ConanFile): \n\
58+
name = "cmake" \n\
59+
package_type = "application" \n\
60+
version = '\""${CMAKE_VERSION}\""' \n\
61+
description = "CMake, the cross-platform, open-source build system." \n\
62+
homepage = "https://github.com/Kitware/CMake" \n\
63+
license = "BSD-3-Clause" \n\
64+
topics = ("build", "installer") \n\
65+
settings = "os", "arch" \n\
66+
def package(self): \n\
67+
self.copy("*") \n\
68+
def package_info(self): \n\
69+
self.cpp_info.libs = tools.collect_libs(self)' >> /usr/local/cmake/conanfile.py && \
70+
conan export-pkg . cmake/${CMAKE_VERSION}@ -s os="Linux" -s arch="ppc64le" && \
71+
conan profile update settings.compiler.libcxx=libstdc++11 default && \
72+
popd && \
73+
mkdir -p $HOME/.cargo/bin/ && \
74+
make -j$(nproc)
75+
76+
77+
FROM registry.access.redhat.com/ubi9/ubi:9.3
78+
79+
RUN yum install libatomic openblas-devel -y
80+
81+
COPY --from=build /tmp/milvus/bin/ /milvus/bin/
82+
COPY --from=build /tmp/milvus/configs/ /milvus/configs/
83+
COPY --from=build /tmp/milvus/internal/core/output/lib64/ /milvus/lib/
84+
COPY --from=build /tmp/milvus/internal/core/output/lib/* /milvus/lib/
85+
86+
ENV PATH=/milvus/bin:$PATH
87+
ENV LD_LIBRARY_PATH=/milvus/lib:$LD_LIBRARY_PATH:/usr/lib
88+
ENV LD_PRELOAD=/milvus/lib/libjemalloc.so
89+
ENV MALLOC_CONF=background_thread:true
90+
91+
# Add Tini
92+
ADD https://github.com/krallin/tini/releases/download/v0.19.0/tini-ppc64le /tini
93+
RUN chmod +x /tini
94+
ENTRYPOINT ["/tini", "--"]
95+
96+
WORKDIR /milvus/

m/milvus/milvus-v2.5.3-ubi9.3.sh

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
#!/bin/bash -ex
2+
# ----------------------------------------------------------------------------
3+
#
4+
# Package : milvus
5+
# Version : 2.4.11
6+
# Source repo : https://github.com/milvus-io/milvus
7+
# Tested on : UBI 9.3 (docker)
8+
# Language : C++, Go
9+
# Travis-Check : False
10+
# Script License: Apache License, Version 2 or later
11+
# Maintainer : Sumit Dubey <[email protected]>
12+
#
13+
# Disclaimer: This script has been tested in root mode on given
14+
# ========== platform using the mentioned version of the package.
15+
# It may not work as expected with newer versions of the
16+
# package and/or distribution. In such case, please
17+
# contact "Maintainer" of this script.
18+
#
19+
# ----------------------------------------------------------------------------
20+
21+
SCRIPT_PACKAGE_VERSION=v2.5.3
22+
PACKAGE_NAME=milvus
23+
PACKAGE_VERSION=${SCRIPT_PACKAGE_VERSION}
24+
PACKAGE_URL=https://github.com/milvus-io/${PACKAGE_NAME}
25+
CMAKE_VERSION=3.30.5
26+
CMAKE_REQUIRED_VERSION=3.30.5
27+
PYTHON_VERSION=3.10.2
28+
GO_VERSION=1.22.6
29+
SCRIPT_PATH=$(dirname $(realpath $0))
30+
wdir=`pwd`
31+
32+
for i in "$@"; do
33+
case $i in
34+
--power10)
35+
APPLYMCPU=1
36+
echo "Optimizing for Power 10"
37+
shift
38+
;;
39+
-*|--*)
40+
echo "Unknown option $i"
41+
exit 3
42+
;;
43+
*)
44+
PACKAGE_VERSION=$i
45+
echo "Building ${PACKAGE_NAME} ${PACKAGE_VERSION}"
46+
;;
47+
esac
48+
done
49+
50+
create_cmake_conanfile()
51+
{
52+
touch /usr/local/cmake/conanfile.py
53+
cat <<EOT >> /usr/local/cmake/conanfile.py
54+
from conans import ConanFile, tools
55+
class CmakeConan(ConanFile):
56+
name = "cmake"
57+
package_type = "application"
58+
version = "${CMAKE_REQUIRED_VERSION}"
59+
description = "CMake, the cross-platform, open-source build system."
60+
homepage = "https://github.com/Kitware/CMake"
61+
license = "BSD-3-Clause"
62+
topics = ("build", "installer")
63+
settings = "os", "arch"
64+
def package(self):
65+
self.copy("*")
66+
def package_info(self):
67+
self.cpp_info.libs = tools.collect_libs(self)
68+
EOT
69+
}
70+
71+
#Install centos and epel repos
72+
yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/CRB/ppc64le/os
73+
yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream//ppc64le/os
74+
yum config-manager --add-repo https://mirror.stream.centos.org/9-stream/BaseOS/ppc64le/os
75+
#rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official
76+
rpm --import https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
77+
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
78+
79+
#Install and setup deps
80+
yum install -y --allowerasing make wget git sudo curl zip unzip tar pkg-config perl-IPC-Cmd perl-Digest-SHA perl-FindBin perl-File-Compare openssl-devel scl-utils openblas-devel rust cargo gcc gcc-c++ libstdc++-static which libaio libuuid-devel ncurses-devel ccache libtool m4 autoconf automake ninja-build zlib-devel libffi-devel java-11-openjdk-devel gfortran yum-utils patchelf hdf5-devel sqlite-devel bzip2-devel xz-devel perl-open.noarch texinfo diffutils
81+
export JAVA_HOME=$(compgen -G '/usr/lib/jvm/java-11-openjdk-*')
82+
export JRE_HOME=${JAVA_HOME}/jre
83+
export PATH=${JAVA_HOME}/bin:$PATH
84+
85+
#Install cmake
86+
cd $wdir
87+
if [ -z "$(ls -A $wdir/cmake-${CMAKE_VERSION})" ]; then
88+
wget -c https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz
89+
tar -zxvf cmake-${CMAKE_VERSION}.tar.gz
90+
rm -rf cmake-${CMAKE_VERSION}.tar.gz
91+
cd cmake-${CMAKE_VERSION}
92+
./bootstrap --prefix=/usr/local/cmake --parallel=2 -- -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON
93+
else
94+
cd cmake-${CMAKE_VERSION}
95+
fi
96+
make install -j$(nproc)
97+
export PATH=/usr/local/cmake/bin:$PATH
98+
cmake --version
99+
100+
#Install Python from source
101+
cd $wdir
102+
if [ -z "$(ls -A $wdir/Python-${PYTHON_VERSION})" ]; then
103+
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
104+
tar xzf Python-${PYTHON_VERSION}.tgz
105+
rm -rf Python-${PYTHON_VERSION}.tgz
106+
cd Python-${PYTHON_VERSION}
107+
./configure --enable-loadable-sqlite-extensions
108+
make -j ${nproc}
109+
else
110+
cd Python-${PYTHON_VERSION}
111+
fi
112+
make altinstall
113+
ln -sf $(which python3.10) /usr/bin/python3
114+
ln -sf $(which python3.10) /usr/bin/python
115+
ln -sf $(which pip3.10) /usr/bin/pip3
116+
python3 -V && pip3 -V
117+
118+
#Install Python dependencies
119+
pip3 install conan==1.64.1 setuptools==59.5.0
120+
121+
#Install Golang
122+
cd $wdir
123+
wget https://go.dev/dl/go${GO_VERSION}.linux-ppc64le.tar.gz
124+
rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-ppc64le.tar.gz
125+
rm -rf go${GO_VERSION}.linux-ppc64le.tar.gz
126+
export PATH=/usr/local/go/bin:$PATH
127+
go version
128+
export PATH=$PATH:$HOME/go/bin
129+
130+
#Install docker
131+
#yum install iptables-nft -y
132+
#yum config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
133+
#yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
134+
#mkdir -p /etc/docker
135+
#touch /etc/docker/daemon.json
136+
#cat <<EOT > /etc/docker/daemon.json
137+
#{
138+
#"ipv6": true,
139+
#"fixed-cidr-v6": "2001:db8:1::/64",
140+
#"mtu": 1450
141+
#}
142+
#EOT
143+
#dockerd > /dev/null 2>&1 &
144+
#sleep 5
145+
#docker run hello-world
146+
147+
#Get milvus source and apply patch
148+
cd $wdir
149+
git clone -b ${PACKAGE_VERSION} ${PACKAGE_URL}
150+
cd ${PACKAGE_NAME}
151+
git apply ${SCRIPT_PATH}/${PACKAGE_NAME}-${SCRIPT_PACKAGE_VERSION}.patch
152+
if [ "$APPLYMCPU" -eq 1 ]; then
153+
sed -i "53d" ./internal/core/CMakeLists.txt
154+
sed -i '53i set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -mcpu=power10")' ./internal/core/CMakeLists.txt
155+
fi
156+
157+
#Build
158+
pushd /usr/local/cmake
159+
create_cmake_conanfile
160+
conan export-pkg . cmake/${CMAKE_REQUIRED_VERSION}@ -s os="Linux" -s arch="ppc64le"
161+
conan profile update settings.compiler.libcxx=libstdc++11 default
162+
popd
163+
export VCPKG_FORCE_SYSTEM_BINARIES=1
164+
mkdir -p $HOME/.cargo/bin/
165+
ret=0
166+
make -j$(nproc) || ret=$?
167+
if [ "$ret" -ne 0 ]
168+
then
169+
echo "FAIL: Build failed."
170+
exit 1
171+
fi
172+
export MILVUS_BIN=$wdir/${PACKAGE_NAME}/bin/milvus
173+
174+
#Cpp unit tests
175+
cd $wdir/${PACKAGE_NAME}/
176+
make test-cpp -j$(nproc) || ret=$?
177+
if [ "$ret" -ne 0 ]
178+
then
179+
echo "Cpp Tests fail."
180+
exit 2
181+
fi
182+
183+
#Start Milvus dev stack
184+
#cd $wdir/${PACKAGE_NAME}/
185+
#docker compose -f ./deployments/docker/dev/docker-compose.yml up -d
186+
#sleep 10
187+
188+
#Go unit tests
189+
#cd $wdir/${PACKAGE_NAME}/
190+
#make test-go -j$(nproc) || ret=$?
191+
#if [ "$ret" -ne 0 ]
192+
#then
193+
# echo "Go Tests fail."
194+
# exit 2
195+
#fi
196+
197+
# Conclude
198+
set +ex
199+
echo "Complete: Build and Cpp Test successful! Milvus binary available at [$MILVUS_BIN]"
200+
echo "10 Azure related tests were disabled: https://github.com/milvus-io/milvus/pull/29021"
201+
echo "Golang tests were skipped"
202+

0 commit comments

Comments
 (0)