51 lines
1.3 KiB
Docker
51 lines
1.3 KiB
Docker
FROM alpine:latest AS base
|
|
|
|
# 根据目标架构设置构建参数
|
|
ARG TARGETARCH
|
|
|
|
RUN apk update && apk add --no-cache \
|
|
git \
|
|
wget \
|
|
make \
|
|
cmake \
|
|
libstdc++ \
|
|
gcc \
|
|
g++ \
|
|
musl-dev \
|
|
automake \
|
|
libtool \
|
|
autoconf \
|
|
linux-headers \
|
|
perl
|
|
|
|
FROM base AS build
|
|
|
|
ARG XXXIG_PROXY_VERSION
|
|
ARG TARGETARCH
|
|
ARG BUILDPLATFORM
|
|
ARG TARGETPLATFORM
|
|
|
|
RUN git clone --recursive https://github.com/wangdefaa/xxxig-proxy.git && \
|
|
cd xxxig-proxy && \
|
|
git checkout ${XXXIG_PROXY_VERSION}
|
|
|
|
WORKDIR /xxxig-proxy
|
|
|
|
# 先编译静态依赖(libuv/OpenSSL)到 scripts/deps,再静态链接构建 proxy
|
|
RUN mkdir build && cd scripts && chmod +x ./*.sh && \
|
|
if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
|
MAKE_JOBS="-j2"; \
|
|
else \
|
|
MAKE_JOBS="-j$(nproc)"; \
|
|
fi && \
|
|
echo "Building with parallel jobs: $MAKE_JOBS (cross-compile: $([ "$BUILDPLATFORM" != "$TARGETPLATFORM" ] && echo yes || echo no))" && \
|
|
./build_deps.sh $MAKE_JOBS && cd ../build && \
|
|
cmake .. -DCMAKE_BUILD_TYPE=Release -DXMRIG_DEPS=scripts/deps -DBUILD_STATIC=ON && \
|
|
make $MAKE_JOBS
|
|
|
|
FROM scratch
|
|
|
|
ARG TARGETARCH
|
|
|
|
COPY --from=build /xxxig-proxy/build/xxxig-proxy /linux_${TARGETARCH}/xxxig-proxy
|
|
COPY --from=build /xxxig-proxy/src/config.json /linux_${TARGETARCH}/config.json |