fix: Alpine 改用 depends 系统实现纯静态链接
Some checks failed
Build and Release Mond / build-and-test (arm64, alpine) (push) Failing after 23s
Build and Release Mond / build-and-test (amd64, alpine) (push) Failing after 31s
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 1m2s
Build and Release Mond / release (push) Has been skipped
Some checks failed
Build and Release Mond / build-and-test (arm64, alpine) (push) Failing after 23s
Build and Release Mond / build-and-test (amd64, alpine) (push) Failing after 31s
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 1m2s
Build and Release Mond / release (push) Has been skipped
- 放弃使用系统包(zeromq-dev 等只提供动态库) - 改用官方 depends 系统从源代码构建所有依赖 - 添加 libexecinfo-dev 解决 musl 环境 execinfo.h 问题 - 与 Ubuntu 构建方式统一,确保纯静态链接
This commit is contained in:
@@ -3,29 +3,23 @@ FROM alpine:3.18 AS base
|
|||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
|
|
||||||
# 安装构建依赖(包含静态库的 -dev 包)
|
# 安装 depends 系统和 Monero 构建所需的依赖
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
git \
|
git \
|
||||||
wget \
|
wget \
|
||||||
|
curl \
|
||||||
build-base \
|
build-base \
|
||||||
cmake \
|
cmake \
|
||||||
boost-dev \
|
pkg-config \
|
||||||
boost-static \
|
autoconf \
|
||||||
openssl-libs-static \
|
automake \
|
||||||
openssl-dev \
|
libtool \
|
||||||
zeromq-dev \
|
bzip2 \
|
||||||
unbound-dev \
|
xz \
|
||||||
libsodium-static \
|
python3 \
|
||||||
libunwind-static \
|
gperf \
|
||||||
xz-dev \
|
libexecinfo-dev \
|
||||||
readline-static \
|
linux-headers
|
||||||
expat-dev \
|
|
||||||
hidapi-dev \
|
|
||||||
libusb-dev \
|
|
||||||
protobuf-dev \
|
|
||||||
eudev-dev \
|
|
||||||
linux-headers \
|
|
||||||
pkgconfig
|
|
||||||
|
|
||||||
FROM base AS build
|
FROM base AS build
|
||||||
|
|
||||||
@@ -47,26 +41,21 @@ COPY ./init.sh ./init.sh
|
|||||||
|
|
||||||
RUN chmod +x ./init.sh && sed -i 's|/bin/sh|/bin/ash|' ./init.sh && ./init.sh
|
RUN chmod +x ./init.sh && sed -i 's|/bin/sh|/bin/ash|' ./init.sh && ./init.sh
|
||||||
|
|
||||||
# 构建 Monero (mond) - 使用静态链接
|
# 使用官方 depends 系统构建静态依赖(参考 Ubuntu Dockerfile)
|
||||||
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
||||||
MAKE_JOBS="-j2"; \
|
MAKE_JOBS=2; \
|
||||||
else \
|
else \
|
||||||
MAKE_JOBS="-j$(nproc)"; \
|
MAKE_JOBS=$(nproc); \
|
||||||
fi && \
|
fi && \
|
||||||
echo "Building mond with parallel jobs: $MAKE_JOBS" && \
|
if [ "$TARGETARCH" = "arm64" ]; then \
|
||||||
mkdir -p build/release && cd build/release && \
|
DEPENDS_TARGET="aarch64-linux-gnu"; \
|
||||||
cmake ../.. \
|
else \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
DEPENDS_TARGET="x86_64-linux-gnu"; \
|
||||||
-DBUILD_GUI_DEPS=OFF \
|
fi && \
|
||||||
-DARCH=default \
|
echo "Building dependencies for $DEPENDS_TARGET with $MAKE_JOBS parallel jobs" && \
|
||||||
-DSTATIC=ON \
|
make -j$MAKE_JOBS depends target=$DEPENDS_TARGET && \
|
||||||
-DSTACK_TRACE=OFF \
|
|
||||||
-DBUILD_SHARED_LIBS=OFF \
|
|
||||||
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
|
|
||||||
-DCMAKE_EXE_LINKER_FLAGS="-static -static-libgcc -static-libstdc++" && \
|
|
||||||
make $MAKE_JOBS daemon && \
|
|
||||||
mkdir -p /output && \
|
mkdir -p /output && \
|
||||||
cp bin/mond /output/mond
|
cp build/$DEPENDS_TARGET/release/bin/mond /output/mond
|
||||||
|
|
||||||
# 最终阶段 - 只复制静态链接的二进制文件
|
# 最终阶段 - 只复制静态链接的二进制文件
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
|||||||
Reference in New Issue
Block a user