Update Dockerfile and build script to support custom installation prefix

This commit is contained in:
Guofang committed 2026-11-06 11:23:25 +08:00
1 parent 292a8b870a
commit be9078f5af
3 files changed
+49 -25

No files matched your search

+38 -23
View File
@@ -37,17 +37,32 @@ RUN dnf install --assumeyes --enablerepo=crb \
RUN git config --global url."https://wangguofang.net/github.com/".insteadOf "https://github.com/"
# Install prefix of every dependency. Libraries are installed under ${PREFIX}/lib64.
ARG PREFIX=/usr/local
# Make the compiler, CMake, pkg-config and the shell find earlier dependencies under a prefix other
# than the default /usr/local. CMake (>= 3.29) takes its default install prefix from the environment.
ENV PATH=${PREFIX}/bin:${PATH} \
C_INCLUDE_PATH=${PREFIX}/include \
CPLUS_INCLUDE_PATH=${PREFIX}/include \
LIBRARY_PATH=${PREFIX}/lib64:${PREFIX}/lib \
PKG_CONFIG_PATH=${PREFIX}/lib64/pkgconfig:${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig \
CMAKE_PREFIX_PATH=${PREFIX} \
CMAKE_INSTALL_PREFIX=${PREFIX}
RUN test "$(cmake --version | sed -n '1s/[^0-9]*//p' | cut -d. -f2)" -ge 29
RUN --mount=type=bind,from=sources,source=rust,target=/tmp/rust \
mkdir rust-src \
&& tar -xJf "/tmp/rust/rust-1.99.1-$(uname -m)-unknown-linux-gnu.tar.xz" -C rust-src --strip-components=1 \
&& rust-src/install.sh --prefix=/usr/local --without=rust-docs \
&& rust-src/install.sh --prefix=${PREFIX} --without=rust-docs \
&& rm -rf rust-src
RUN --mount=type=bind,from=sources,source=boost_1_83_0.tar.bz2,target=/tmp/boost.tar.bz2 \
mkdir src \
&& tar --extract --bzip2 --file=/tmp/boost.tar.bz2 --directory=src --strip-components=1 \
&& cd src \
&& ./bootstrap.sh --prefix=/usr/local --libdir=/usr/local/lib64 \
&& ./bootstrap.sh --prefix=${PREFIX} --libdir=${PREFIX}/lib64 \
&& ./b2 --jobs="$(nproc)" \
--with-atomic \
--with-chrono \
@@ -73,7 +88,7 @@ RUN --mount=type=bind,from=sources,source=openssl-openssl-3.0.15.tar.gz,target=/
mkdir src \
&& tar --extract --gzip --file=/tmp/openssl.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& ./Configure --prefix=/usr/local no-shared no-tests -fPIC \
&& ./Configure --prefix=${PREFIX} no-shared no-tests -fPIC \
&& make --jobs="$(nproc)" \
&& make install_sw \
&& cd .. \
@@ -111,7 +126,7 @@ RUN --mount=type=bind,from=sources,source=zlib-v1.3.1.tar.gz,target=/tmp/zlib.ta
mkdir src \
&& tar --extract --gzip --file=/tmp/zlib.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --static \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 --static \
&& make --jobs="$(nproc)" \
&& make install \
&& cd .. \
@@ -204,7 +219,7 @@ RUN --mount=type=bind,from=sources,source=gflags-v2.3.1.tar.gz,target=/tmp/gflag
-DINSTALL_HEADERS=ON \
-DINSTALL_SHARED_LIBS=OFF \
-DINSTALL_STATIC_LIBS=ON \
-DLIBRARY_INSTALL_DIR=/usr/local/lib64 \
-DLIBRARY_INSTALL_DIR=${PREFIX}/lib64 \
-DREGISTER_INSTALL_PREFIX=OFF \
&& cmake --build build --parallel "$(nproc)" --target install \
&& rm -rf build src
@@ -227,7 +242,7 @@ RUN --mount=type=bind,from=sources,source=liburing-liburing-2.15.tar.gz,target=/
mkdir src \
&& tar --extract --gzip --file=/tmp/liburing.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --libdevdir=/usr/local/lib64 \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 --libdevdir=${PREFIX}/lib64 \
&& make --jobs="$(nproc)" ENABLE_SHARED=0 library \
&& make ENABLE_SHARED=0 install \
&& cd .. \
@@ -237,7 +252,7 @@ RUN --mount=type=bind,from=sources,source=libaio_0.3.113.orig.tar.gz,target=/tmp
mkdir src \
&& tar --extract --gzip --file=/tmp/libaio.tar.gz --directory=src --strip-components=1 \
&& make --directory=src --jobs="$(nproc)" ENABLE_SHARED=0 \
&& make --directory=src ENABLE_SHARED=0 prefix=/usr/local libdir=/usr/local/lib64 install \
&& make --directory=src ENABLE_SHARED=0 prefix=${PREFIX} libdir=${PREFIX}/lib64 install \
&& rm -rf src
RUN --mount=type=bind,from=sources,source=libdwarf-code-v2.3.2.tar.gz,target=/tmp/libdwarf-code.tar.gz \
@@ -260,7 +275,7 @@ RUN --mount=type=bind,from=sources,source=libsodium-1.0.20-RELEASE.tar.gz,target
&& tar --extract --gzip --file=/tmp/libsodium.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& ./autogen.sh \
&& ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --disable-shared --enable-static --with-pic \
&& ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 --disable-shared --enable-static --with-pic \
&& make --jobs="$(nproc)" \
&& make install \
&& cd .. \
@@ -294,7 +309,7 @@ RUN --mount=type=bind,from=sources,source=numactl-v2.0.19.tar.gz,target=/tmp/num
&& tar --extract --gzip --file=/tmp/numactl.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& ./autogen.sh \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --disable-shared --enable-static \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 --disable-shared --enable-static \
&& make --jobs="$(nproc)" \
&& make install \
&& cd .. \
@@ -397,7 +412,7 @@ RUN --mount=type=bind,from=sources,source=util-linux-2.42.2.tar.xz,target=/tmp/u
mkdir src \
&& tar --extract --xz --file=/tmp/util-linux.tar.xz --directory=src --strip-components=1 \
&& cd src \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 \
--disable-all-programs \
--disable-bash-completion \
--disable-makeinstall-chown \
@@ -497,7 +512,7 @@ RUN --mount=type=bind,from=sources,source=rapidjson-v1.1.0.tar.gz,target=/tmp/ra
&& tar --extract --gzip --file=/tmp/rapidjson.tar.gz --directory=src --strip-components=1 \
&& git -C src apply /tmp/rapidjson-generic-string-ref-assignment.patch \
&& cmake -G Ninja -S src -B build -DCMAKE_BUILD_TYPE=Release \
-DLIB_INSTALL_DIR=/usr/local/lib64 \
-DLIB_INSTALL_DIR=${PREFIX}/lib64 \
-DRAPIDJSON_BUILD_DOC=OFF \
-DRAPIDJSON_BUILD_EXAMPLES=OFF \
-DRAPIDJSON_BUILD_TESTS=OFF \
@@ -548,7 +563,7 @@ RUN --mount=type=bind,from=sources,source=gmp-6.3.0.tar.xz,target=/tmp/gmp.tar.x
mkdir src \
&& tar --extract --xz --file=/tmp/gmp.tar.xz --directory=src --strip-components=1 \
&& cd src \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --disable-shared --enable-static --enable-fat \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 --disable-shared --enable-static --enable-fat \
&& make --jobs="$(nproc)" \
&& make install \
&& cd .. \
@@ -558,7 +573,7 @@ RUN --mount=type=bind,from=sources,source=nettle-3.10.2.tar.gz,target=/tmp/nettl
mkdir src \
&& tar --extract --gzip --file=/tmp/nettle.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 \
--disable-documentation \
--disable-shared \
--enable-static \
@@ -571,7 +586,7 @@ RUN --mount=type=bind,from=sources,source=gnutls-3.8.13.tar.xz,target=/tmp/gnutl
mkdir src \
&& tar --extract --xz --file=/tmp/gnutls.tar.xz --directory=src --strip-components=1 \
&& cd src \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 \
--with-included-libtasn1 \
--with-included-unistring \
--disable-cxx \
@@ -610,7 +625,7 @@ RUN --mount=type=bind,from=sources,source=libyaml-0.2.5.tar.gz,target=/tmp/libya
&& tar --extract --gzip --file=/tmp/libyaml.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& ./bootstrap \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 --disable-shared --enable-static \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 --disable-shared --enable-static \
&& make --jobs="$(nproc)" \
&& make install \
&& cd .. \
@@ -648,7 +663,7 @@ RUN --mount=type=bind,from=sources,source=libunwind-v1.8.3.tar.gz,target=/tmp/li
&& tar --extract --gzip --file=/tmp/libunwind.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& autoreconf --install \
&& CFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 \
&& CFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 \
--disable-shared \
--enable-static \
--disable-tests \
@@ -665,7 +680,7 @@ RUN --mount=type=bind,from=sources,source=jemalloc-5.3.1.tar.gz,target=/tmp/jema
&& tar --extract --gzip --file=/tmp/jemalloc.tar.gz --directory=src --strip-components=1 \
&& cd src \
&& ./autogen.sh \
&& CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure --prefix=/usr/local --libdir=/usr/local/lib64 \
&& CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure --prefix=${PREFIX} --libdir=${PREFIX}/lib64 \
--disable-doc \
--disable-shared \
--enable-static \
@@ -680,8 +695,8 @@ RUN --mount=type=bind,from=sources,source=libproxyprotocol-v1.3.3.tar.gz,target=
mkdir src \
&& tar --extract --gzip --file=/tmp/libproxyprotocol.tar.gz --directory=src --strip-components=1 \
&& gcc -fPIC -c -o src/src/proxy_protocol.o src/src/proxy_protocol.c \
&& ar rcs /usr/local/lib64/libproxyprotocol.a src/src/proxy_protocol.o \
&& cp src/src/proxy_protocol.h /usr/local/include/ \
&& ar rcs ${PREFIX}/lib64/libproxyprotocol.a src/src/proxy_protocol.o \
&& cp src/src/proxy_protocol.h ${PREFIX}/include/ \
&& rm -rf src
RUN --mount=type=bind,from=sources,source=xsimd-14.2.0.tar.gz,target=/tmp/xsimd.tar.gz \
@@ -701,10 +716,10 @@ RUN --mount=type=bind,from=sources,source=thrift-v0.22.0.tar.gz,target=/tmp/thri
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_TUTORIALS=OFF \
-DCMAKE_INSTALL_DIR=/usr/local/lib64/cmake \
-DCMAKE_INSTALL_DIR=${PREFIX}/lib64/cmake \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DLIB_INSTALL_DIR=/usr/local/lib64 \
-DPKGCONFIG_INSTALL_DIR=/usr/local/lib64/pkgconfig \
-DLIB_INSTALL_DIR=${PREFIX}/lib64 \
-DPKGCONFIG_INSTALL_DIR=${PREFIX}/lib64/pkgconfig \
-DWITH_AS3=OFF \
-DWITH_C_GLIB=OFF \
-DWITH_CPP=ON \
@@ -718,7 +733,7 @@ RUN --mount=type=bind,from=sources,source=thrift-v0.22.0.tar.gz,target=/tmp/thri
-DWITH_ZLIB=OFF \
&& cmake --build build --parallel "$(nproc)" --target install \
&& sed -i 's|^libdir=.*|libdir=${prefix}/lib64|' \
/usr/local/lib64/pkgconfig/thrift.pc \
${PREFIX}/lib64/pkgconfig/thrift.pc \
&& rm -rf build src
RUN --mount=type=bind,from=sources,source=snappy-1.2.2.tar.gz,target=/tmp/snappy.tar.gz \