FROM alpine:latest AS base # 根据目标架构设置构建参数 ARG TARGETARCH RUN apk update && apk add --no-cache \ git \ make \ cmake \ libstdc++ \ gcc \ g++ \ automake \ libtool \ autoconf \ linux-headers \ libuv-dev \ openssl-dev \ hwloc-dev FROM base AS build ARG TARGZ_FILE ARG XMRIGCC_VERSION ARG TARGETARCH RUN git clone --recursive https://github.com/Bendr0id/xmrigCC.git && \ mv xmrigCC xxxigcc && \ cd xxxigcc && \ git checkout ${XMRIGCC_VERSION} WORKDIR /xxxigcc COPY ./init.sh ./init.sh # 根据目标架构优化编译 RUN chmod +x ./init.sh && ./init.sh && \ mkdir build && cd scripts && chmod +x ./*.sh && ./build_deps.sh && cd ../build && \ if [ "$TARGETARCH" = "arm64" ]; then \ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DXMRIG_DEPS=scripts/deps \ -DBUILD_STATIC=ON \ -DWITH_ZLIB=ON \ -DWITH_OPENCL=OFF \ -DWITH_CUDA=OFF \ -DARM_TARGET=8; \ elif [ "$TARGETARCH" = "arm" ]; then \ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DXMRIG_DEPS=scripts/deps \ -DBUILD_STATIC=ON \ -DWITH_ZLIB=ON \ -DWITH_OPENCL=OFF \ -DWITH_CUDA=OFF \ -DARM_TARGET=7; \ else \ cmake .. -DCMAKE_BUILD_TYPE=Release \ -DXMRIG_DEPS=scripts/deps \ -DBUILD_STATIC=ON \ -DWITH_ZLIB=ON \ -DWITH_OPENCL=OFF \ -DWITH_CUDA=OFF; \ fi && \ make -j$(nproc) FROM scratch ARG TARGETARCH COPY --from=build /xxxigcc/build/xxxigDaemon /linux_${TARGETARCH}/xxxigDaemon COPY --from=build /xxxigcc/build/xxxigMiner /linux_${TARGETARCH}/xxxigMiner COPY --from=build /xxxigcc/build/xxxigServer /linux_${TARGETARCH}/xxxigServer COPY --from=build /xxxigcc/src/config_cc.json /linux_${TARGETARCH}/config_cc.json COPY --from=build /xxxigcc/src/config.json /linux_${TARGETARCH}/config.json COPY --from=build /xxxigcc/index.html /linux_${TARGETARCH}/index.html