Files
mond/docker/Dockerfile.alpine
Wang Defa 202c36f21e
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 54s
Build and Release Mond / build-and-test (arm64, alpine) (push) Failing after 1m3s
Build and Release Mond / build-and-test (amd64, alpine) (push) Failing after 1m10s
Build and Release Mond / release (push) Has been skipped
fix: Alpine 使用可用的静态库包名称
问题:Alpine 3.18 缺少这些静态包:
- hidapi-static
- libusb-static
- zeromq-static
- expat-static

解决方案:
- 保留存在的 -static 包:boost-static, openssl-libs-static, libsodium-static, libunwind-static, readline-static
- 使用 -dev 包替代不存在的 -static 包:zeromq-dev, hidapi-dev, libusb-dev, expat-dev
- 依靠 CMake 强制标志优先使用 .a 文件:
  * CMAKE_FIND_LIBRARY_SUFFIXES=".a"
  * CMAKE_EXE_LINKER_FLAGS="-static -static-libgcc -static-libstdc++"
2025-12-15 14:28:32 +08:00

75 lines
1.7 KiB
Docker

FROM alpine:3.18 AS base
ARG TARGETARCH
ARG BUILDPLATFORM
# 安装构建依赖(包含静态库的 -dev 包)
RUN apk add --no-cache \
git \
wget \
build-base \
cmake \
boost-static \
openssl-libs-static \
openssl-dev \
zeromq-dev \
libsodium-static \
libunwind-static \
xz-dev \
readline-static \
expat-dev \
hidapi-dev \
libusb-dev \
protobuf-dev \
eudev-dev \
linux-headers \
pkgconfig
FROM base AS build
ARG MONERO_VERSION=v0.18.3.4
ARG TARGETARCH
ARG BUILDPLATFORM
ARG TARGETPLATFORM
# 克隆 Monero 项目
RUN git clone --recursive https://github.com/monero-project/monero.git && \
cd monero && \
git checkout ${MONERO_VERSION} && \
git submodule update --init --force
WORKDIR /monero
# 复制并运行 init.sh 脚本进行修改
COPY ./init.sh ./init.sh
RUN chmod +x ./init.sh && sed -i 's|/bin/sh|/bin/ash|' ./init.sh && ./init.sh
# 构建 Monero (mond) - 使用静态链接
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
MAKE_JOBS="-j2"; \
else \
MAKE_JOBS="-j$(nproc)"; \
fi && \
echo "Building mond 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 \
-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 && \
cp bin/mond /output/mond
# 最终阶段 - 只复制静态链接的二进制文件
FROM scratch
ARG TARGETARCH
COPY --from=build /output/mond /linux_${TARGETARCH}/mond