fix: Alpine 使用 depends 系统实现纯静态链接
Some checks failed
Build and Release Mond / build-and-test (arm64, ubuntu) (push) Successful in 40s
Build and Release Mond / build-and-test (amd64, ubuntu) (push) Successful in 55s
Build and Release Mond / build-and-test (arm64, alpine) (push) Failing after 2m16s
Build and Release Mond / build-and-test (amd64, alpine) (push) Failing after 9m9s
Build and Release Mond / release (push) Has been skipped

问题修复:
- Alpine 之前使用简单 cmake 方法导致动态链接(依赖 libzmq.so, libsodium.so, libunbound.so)
- 运行时错误:Error loading shared library

解决方案:
1. 移除所有动态库开发包(boost-*, zeromq-dev, unbound-dev 等)
2. 只保留 depends 系统所需的构建工具
3. 使用官方 depends 系统:make depends target=$DEPENDS_TARGET
4. 与 Ubuntu 构建流程完全统一
This commit is contained in:
2025-12-15 14:14:10 +08:00
parent 594dfb2e7d
commit 716d771ce4

View File

@@ -3,37 +3,22 @@ FROM alpine:3.18 AS base
ARG TARGETARCH
ARG BUILDPLATFORM
# 安装构建依赖
# 安装构建依赖depends 系统所需工具)
RUN apk add --no-cache \
git \
wget \
curl \
build-base \
cmake \
boost-dev \
boost-static \
boost-filesystem \
boost-thread \
boost-date_time \
boost-chrono \
boost-serialization \
boost-program_options \
boost-locale \
boost-system \
boost-regex \
openssl-dev \
zeromq-dev \
unbound-dev \
libsodium-dev \
libunwind-dev \
xz-dev \
readline-dev \
expat-dev \
hidapi-dev \
libusb-dev \
protobuf-dev \
eudev-dev \
linux-headers \
pkgconfig
pkgconfig \
autoconf \
automake \
libtool \
bzip2 \
xz \
python3 \
gperf \
linux-headers
FROM base AS build
@@ -55,20 +40,25 @@ COPY ./init.sh ./init.sh
RUN chmod +x ./init.sh && sed -i 's|/bin/sh|/bin/ash|' ./init.sh && ./init.sh
# 构建 Monero (mond)
# 使用官方 depends 系统构建静态依赖(参考 .source/Dockerfile
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
MAKE_JOBS="-j2"; \
MAKE_JOBS=2; \
else \
MAKE_JOBS="-j$(nproc)"; \
MAKE_JOBS=$(nproc); \
fi && \
echo "Building with parallel jobs: $MAKE_JOBS" && \
mkdir -p build/release && cd build/release && \
cmake ../.. -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI_DEPS=OFF -DARCH=default -DSTATIC=ON -DSTACK_TRACE=OFF && \
make $MAKE_JOBS daemon
if [ "$TARGETARCH" = "arm64" ]; then \
DEPENDS_TARGET="aarch64-linux-gnu"; \
else \
DEPENDS_TARGET="x86_64-linux-gnu"; \
fi && \
echo "Building dependencies for $DEPENDS_TARGET with $MAKE_JOBS parallel jobs" && \
make -j$MAKE_JOBS depends target=$DEPENDS_TARGET && \
mkdir -p /output && \
cp build/$DEPENDS_TARGET/release/bin/mond /output/mond
# 最终阶段 - 只复制二进制文件
# 最终阶段 - 只复制静态链接的二进制文件
FROM scratch
ARG TARGETARCH
COPY --from=build /monero/build/release/bin/mond /linux_${TARGETARCH}/mond
COPY --from=build /output/mond /linux_${TARGETARCH}/mond