fix: 使用 Monero depends 系统实现完全静态链接
Some checks failed
Build and Release Mond / build-and-test (arm64, alpine) (push) Successful in 26s
Build and Release Mond / build-and-test (amd64, alpine) (push) Successful in 38s
Build and Release Mond / build-and-test (arm64, ubuntu) (push) Failing after 6m39s
Build and Release Mond / build-and-test (amd64, ubuntu) (push) Failing after 8m37s
Build and Release Mond / release (push) Has been skipped
Some checks failed
Build and Release Mond / build-and-test (arm64, alpine) (push) Successful in 26s
Build and Release Mond / build-and-test (amd64, alpine) (push) Successful in 38s
Build and Release Mond / build-and-test (arm64, ubuntu) (push) Failing after 6m39s
Build and Release Mond / build-and-test (amd64, ubuntu) (push) Failing after 8m37s
Build and Release Mond / release (push) Has been skipped
- 添加 depends 系统所需的构建工具(autoconf, automake, libtool 等) - 在构建前先使用 contrib/depends 系统编译所有依赖的静态版本 - 使用 toolchain.cmake 确保链接到 depends 构建的静态库 - 支持 amd64 和 arm64 两种架构 - 最终镜像改回 FROM scratch,产生完全独立的可执行文件 Monero 的 depends 系统会从源代码编译所有依赖库(boost、openssl、 zeromq、unbound、libevent、nettle、gmp 等)的静态版本,解决了 系统包管理器中静态库缺失或版本不匹配的问题。 生成的二进制文件可以在任何 Linux 系统上独立运行,无需安装依赖。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,13 +5,21 @@ ARG BUILDPLATFORM
|
|||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
# 安装构建依赖
|
# 安装构建依赖(包括 depends 系统所需工具)
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
git \
|
git \
|
||||||
wget \
|
wget \
|
||||||
|
curl \
|
||||||
build-essential \
|
build-essential \
|
||||||
cmake \
|
cmake \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
libtool \
|
||||||
|
bzip2 \
|
||||||
|
xz-utils \
|
||||||
|
python3 \
|
||||||
|
gperf \
|
||||||
libboost-all-dev \
|
libboost-all-dev \
|
||||||
libssl-dev \
|
libssl-dev \
|
||||||
libzmq3-dev \
|
libzmq3-dev \
|
||||||
@@ -51,43 +59,45 @@ COPY ./init.sh ./init.sh
|
|||||||
|
|
||||||
RUN chmod +x ./init.sh && ./init.sh
|
RUN chmod +x ./init.sh && ./init.sh
|
||||||
|
|
||||||
# 构建 Monero (mond) - 使用动态链接
|
# 使用 depends 系统构建所有静态依赖
|
||||||
|
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
||||||
|
MAKE_JOBS=2; \
|
||||||
|
else \
|
||||||
|
MAKE_JOBS=$(nproc); \
|
||||||
|
fi && \
|
||||||
|
if [ "$TARGETARCH" = "arm64" ]; then \
|
||||||
|
DEPENDS_HOST="aarch64-linux-gnu"; \
|
||||||
|
else \
|
||||||
|
DEPENDS_HOST="x86_64-linux-gnu"; \
|
||||||
|
fi && \
|
||||||
|
echo "Building dependencies for $DEPENDS_HOST with $MAKE_JOBS parallel jobs" && \
|
||||||
|
cd contrib/depends && \
|
||||||
|
make HOST=$DEPENDS_HOST -j$MAKE_JOBS
|
||||||
|
|
||||||
|
# 构建 Monero (mond) - 使用静态链接和 depends
|
||||||
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
||||||
MAKE_JOBS="-j2"; \
|
MAKE_JOBS="-j2"; \
|
||||||
else \
|
else \
|
||||||
MAKE_JOBS="-j$(nproc)"; \
|
MAKE_JOBS="-j$(nproc)"; \
|
||||||
fi && \
|
fi && \
|
||||||
echo "Building with parallel jobs: $MAKE_JOBS" && \
|
if [ "$TARGETARCH" = "arm64" ]; then \
|
||||||
|
DEPENDS_HOST="aarch64-linux-gnu"; \
|
||||||
|
else \
|
||||||
|
DEPENDS_HOST="x86_64-linux-gnu"; \
|
||||||
|
fi && \
|
||||||
|
echo "Building mond for $DEPENDS_HOST with parallel jobs: $MAKE_JOBS" && \
|
||||||
mkdir -p build/release && cd build/release && \
|
mkdir -p build/release && cd build/release && \
|
||||||
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI_DEPS=OFF -DARCH=default && \
|
cmake ../.. \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DBUILD_GUI_DEPS=OFF \
|
||||||
|
-DARCH=default \
|
||||||
|
-DSTATIC=ON \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=/monero/contrib/depends/$DEPENDS_HOST/share/toolchain.cmake && \
|
||||||
make $MAKE_JOBS daemon
|
make $MAKE_JOBS daemon
|
||||||
|
|
||||||
# 最终阶段 - 使用 Ubuntu 基础镜像以支持动态链接
|
# 最终阶段 - 只复制静态链接的二进制文件
|
||||||
FROM ubuntu:22.04
|
FROM scratch
|
||||||
|
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
|
||||||
# 安装运行时依赖
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
libboost-chrono1.74.0 \
|
|
||||||
libboost-date-time1.74.0 \
|
|
||||||
libboost-filesystem1.74.0 \
|
|
||||||
libboost-locale1.74.0 \
|
|
||||||
libboost-program-options1.74.0 \
|
|
||||||
libboost-regex1.74.0 \
|
|
||||||
libboost-serialization1.74.0 \
|
|
||||||
libboost-system1.74.0 \
|
|
||||||
libboost-thread1.74.0 \
|
|
||||||
libssl3 \
|
|
||||||
libzmq5 \
|
|
||||||
libunbound8 \
|
|
||||||
libsodium23 \
|
|
||||||
libunwind8 \
|
|
||||||
libreadline8 \
|
|
||||||
libhidapi-libusb0 \
|
|
||||||
libprotobuf23 \
|
|
||||||
libudev1 \
|
|
||||||
ca-certificates \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY --from=build /monero/build/release/bin/mond /linux_${TARGETARCH}/mond
|
COPY --from=build /monero/build/release/bin/mond /linux_${TARGETARCH}/mond
|
||||||
|
|||||||
Reference in New Issue
Block a user