From 1b7f80426835c435bd10e818741e5c0793f66a3e Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 8 Mar 2023 00:26:16 +0800 Subject: [PATCH] build: perf construction of AdGuardHome --- Dockerfile | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 913d3d2..37c8ea6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,16 +11,14 @@ RUN make UPX_CMAKE_CONFIG_FLAGS=-DCMAKE_EXE_LINKER_FLAGS=-static WORKDIR ./build/release/ RUN strip upx && mv upx /tmp/ -FROM ${GOLANG} AS adguard -ENV ADGUARD="0.107.20" -RUN apk add git make npm yarn -RUN git clone https://github.com/AdguardTeam/AdGuardHome.git -b v${ADGUARD} --depth=1 -WORKDIR ./AdGuardHome/ -RUN make js-deps -RUN make js-build -RUN make CHANNEL="release" VERBOSE=1 go-build && mv AdGuardHome /tmp/ +FROM ${GOLANG} AS dnsproxy +ENV DNSPROXY="0.48.0" +RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY}.tar.gz && tar xf v${DNSPROXY}.tar.gz +WORKDIR ./dnsproxy-${DNSPROXY}/ +RUN go get +RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DNSPROXY} -s -w" && mv dnsproxy /tmp/ COPY --from=upx /tmp/upx /usr/bin/ -RUN upx -9 /tmp/AdGuardHome +RUN upx -9 /tmp/dnsproxy FROM ${GOLANG} AS overture ENV OVERTURE="1.8" @@ -31,14 +29,28 @@ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=v${OVERTUR COPY --from=upx /tmp/upx /usr/bin/ RUN upx -9 /tmp/overture -FROM ${GOLANG} AS dnsproxy -ENV DNSPROXY="0.48.0" -RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY}.tar.gz && tar xf v${DNSPROXY}.tar.gz -WORKDIR ./dnsproxy-${DNSPROXY}/ +FROM ${ALPINE} AS adguard-src +RUN apk add git +ENV ADGUARD="0.107.25" +RUN git clone https://github.com/AdguardTeam/AdGuardHome.git -b v${ADGUARD} --depth=1 + +FROM alpine:3.16 AS adguard-web +RUN apk add make npm +COPY --from=adguard-src /AdGuardHome/ /AdGuardHome/ +WORKDIR /AdGuardHome/ +RUN make js-deps +RUN make js-build +RUN mv ./build/static/ /tmp/ + +FROM ${GOLANG} AS adguard +RUN apk add git make +COPY --from=adguard-src /AdGuardHome/ /AdGuardHome/ +WORKDIR /AdGuardHome/ RUN go get -RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DNSPROXY} -s -w" && mv dnsproxy /tmp/ +COPY --from=adguard-web /tmp/static/ ./build/static/ +RUN make CHANNEL="release" VERBOSE=1 go-build && mv AdGuardHome /tmp/ COPY --from=upx /tmp/upx /usr/bin/ -RUN upx -9 /tmp/dnsproxy +RUN upx -9 /tmp/AdGuardHome FROM ${RUST} AS rust-mods RUN apk add libc-dev openssl-dev @@ -55,8 +67,7 @@ COPY --from=rust-mods /tmp/libto_json.a /cleardns/src/target/release/ WORKDIR /cleardns/bin/ RUN cmake -DCMAKE_EXE_LINKER_FLAGS=-static .. && make && mv cleardns /tmp/ COPY --from=upx /tmp/upx /usr/bin/ -WORKDIR /tmp/ -RUN strip cleardns && upx -9 cleardns +RUN strip /tmp/cleardns && upx -9 /tmp/cleardns FROM ${ALPINE} AS build RUN apk add xz @@ -65,10 +76,10 @@ RUN wget https://res.dnomd343.top/Share/cleardns/gfwlist.txt.xz && \ wget https://res.dnomd343.top/Share/cleardns/china-ip.txt.xz && \ wget https://res.dnomd343.top/Share/cleardns/chinalist.txt.xz && \ xz -d *.xz && tar cJf assets.tar.xz *.txt && rm *.txt -COPY --from=adguard /tmp/AdGuardHome /release/usr/bin/ -COPY --from=overture /tmp/overture /release/usr/bin/ -COPY --from=dnsproxy /tmp/dnsproxy /release/usr/bin/ COPY --from=cleardns /tmp/cleardns /release/usr/bin/ +COPY --from=dnsproxy /tmp/dnsproxy /release/usr/bin/ +COPY --from=overture /tmp/overture /release/usr/bin/ +COPY --from=adguard /tmp/AdGuardHome /release/usr/bin/ FROM ${ALPINE} COPY --from=build /release/ /