Files
p2pool/docker/Dockerfile
T
wangdefaandClaude Opus 4.8 3b024fdc10
Build and Release / release (push) Has been skipped
Build and Release / build-and-test (amd64) (push) Failing after 3m8s
Build and Release / build-and-test (arm64) (push) Failing after 7m31s
重构为 musl 纯静态打包,配置迁 /etc,对齐三项目
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 14:55:12 +08:00

75 lines
4.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# p2pool musl 纯静态构建(参照上游官方 c-cpp.yml 的 Alpine static release 流程)
# Alpine + 自编 external 静态库(curl/libuv/libzmq) + 上游 boringssl + -DSTATIC_BINARY=ON
# 产物 fully-staticldd: not a dynamic executable),glibc/musl 任意发行版直接运行。
# 为何 muslmusl getaddrinfo 自包含,全静态可跨发行版;glibc 静态会因 NSS dlopen 失败。
FROM alpine:3.21 AS build
ARG P2POOL_VERSION
ARG TARGETARCH
RUN apk add --no-cache git cmake gcc g++ make linux-headers perl
RUN git clone https://github.com/SChernykh/p2pool /src/p2pool
WORKDIR /src/p2pool
# 只拉构建所需子模块:8 个常规依赖 + grpc 仅取其 boringssl(p2pool cmake/ssl 无条件依赖)
# 不递归 grpc 其余巨型子模块(abseil/protobuf 等)WITH_GRPC=OFF 不编 grpc 本体。
RUN git checkout ${P2POOL_VERSION} && \
git submodule update --init --recursive \
external/src/RandomX external/src/rapidjson external/src/cppzmq \
external/src/libuv external/src/libzmq external/src/robin-hood-hashing \
external/src/curl external/src/miniupnp && \
git submodule update --init external/src/grpc && \
git -C external/src/grpc submodule update --init third_party/boringssl-with-bazel
# external libcurlHTTP + p2pool boringssl 集成(保留 rpc-ssl 连 HTTPS monerod)。
# 完整照搬官方 c-cpp.yml 的 curl flagsP2POOL_BORINGSSL=ON 是上游给 curl 打的独立
# boringssl TLS 后端补丁(不走 curl 标准 CURL_ENABLE_SSL 路径,故二者共存且仍支持 --rpc-ssl)。
# 一整套 CURL_DISABLE_*(尤其 SRP/AWS/*_AUTH) 用于跳过会引用 OpenSSL::SSL imported target 的
# curl_openssl_check_exists 符号检测——新版 cmake 在 try_compile 阶段校验该 target 必失败,少一个都会触发。
RUN cd external/src/curl && cmake . -DCMAKE_BUILD_TYPE=Release \
-DCURL_DROP_UNUSED=ON -DCURL_DISABLE_TYPECHECK=ON \
-DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG=ON -DCURL_DISABLE_SHA512_256=ON \
-DPICKY_COMPILER=OFF -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF \
-DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF \
-DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON \
-DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF \
-DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF \
-DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON \
-DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON \
-DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON \
-DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON \
-DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON \
-DCURL_DISABLE_VERBOSE_STRINGS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF \
-DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF \
-DENABLE_UNIX_SOCKETS=OFF -DBUILD_TESTING=OFF -DUSE_NGHTTP2=OFF \
-DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON \
-DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON \
-DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON \
-DCURL_DISABLE_NEGOTIATE_AUTH=ON \
-DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include && \
make -j"$(nproc)"
# external libuv 静态
RUN cd external/src/libuv && mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF && \
make -j"$(nproc)"
# external libzmq 静态
RUN cd external/src/libzmq && mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF \
-DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF && \
make -j"$(nproc)"
# p2pool 主体:纯静态(STATIC_BINARY) + 禁 grpc本体 + 禁合并挖矿捐赠(gitea-p2pool 定制)
RUN if [ "$TARGETARCH" = "arm64" ]; then ARCH_ID=aarch64; else ARCH_ID=x86_64; fi && \
mkdir build && cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DSTATIC_BINARY=ON -DWITH_GRPC=OFF -DWITH_MERGE_MINING_DONATION=OFF \
-DARCH_ID="$ARCH_ID" \
-DCMAKE_C_FLAGS='-Wl,-s -Wl,--gc-sections' \
-DCMAKE_CXX_FLAGS='-Wl,-s -Wl,--gc-sections' && \
make -j"$(nproc)" p2pool && cp p2pool /p2pool
FROM scratch
ARG TARGETARCH
COPY --from=build /p2pool /linux_${TARGETARCH}/p2pool