From 854ee8a2d29163246c31fe8dc40de8fa44c86ab6 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 7 Mar 2023 22:43:34 +0800 Subject: [PATCH 1/5] build: golang version `1.19` --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 194e546..3b3aa3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ ARG ALPINE="alpine:3.17" ARG RUST="rust:1.67-alpine3.17" -ARG GOLANG="golang:1.18-alpine3.16" +ARG GOLANG="golang:1.19-alpine3.17" FROM ${ALPINE} AS upx RUN apk add build-base cmake From 2cc3b91092e77fd4f9669b1ea54b12bb5d781835 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Tue, 7 Mar 2023 23:00:19 +0800 Subject: [PATCH 2/5] build: dnsproxy version `0.48.0` --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3b3aa3d..913d3d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,14 +26,16 @@ FROM ${GOLANG} AS overture ENV OVERTURE="1.8" RUN wget https://github.com/shawn1m/overture/archive/refs/tags/v${OVERTURE}.tar.gz && tar xf v${OVERTURE}.tar.gz WORKDIR ./overture-${OVERTURE}/main/ +RUN go get RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=v${OVERTURE} -s -w" && mv main /tmp/overture COPY --from=upx /tmp/upx /usr/bin/ RUN upx -9 /tmp/overture FROM ${GOLANG} AS dnsproxy -ENV DNSPROXY="0.46.4" +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/dnsproxy From 1b7f80426835c435bd10e818741e5c0793f66a3e Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 8 Mar 2023 00:26:16 +0800 Subject: [PATCH 3/5] 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/ / From 831ce3e4d730389ea8784f9aee2ddb457d9233bf Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 8 Mar 2023 00:42:33 +0800 Subject: [PATCH 4/5] fix: construction error under node18 --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37c8ea6..2ca2166 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,12 +34,13 @@ 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 +FROM ${ALPINE} AS adguard-web RUN apk add make npm COPY --from=adguard-src /AdGuardHome/ /AdGuardHome/ WORKDIR /AdGuardHome/ RUN make js-deps -RUN make js-build +# TODO: for node18, remove the OpenSSL compatibility option after AdGuardHome project upgrade +RUN env NODE_OPTIONS="--openssl-legacy-provider" make js-build RUN mv ./build/static/ /tmp/ FROM ${GOLANG} AS adguard From ec7ecb317cac6d0e998deba9371f4a6d7a582247 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 8 Mar 2023 10:13:24 +0800 Subject: [PATCH 5/5] update: optimize log output --- src/utils/process.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/process.c b/src/utils/process.c index 7ee110c..9552385 100644 --- a/src/utils/process.c +++ b/src/utils/process.c @@ -55,7 +55,6 @@ void process_exec(process *proc) { log_perror("%s fork error -> ", proc->name); server_exit(EXIT_FORK_ERROR); } else if (pid == 0) { // child process - log_debug("Subprocess fork success -> PID = %d", getpid()); if (chdir(proc->cwd)) { // change working directory log_perror("%s with invalid cwd `%s` -> ", proc->name, proc->cwd); exit(EXIT_EXEC_ERROR); @@ -155,11 +154,11 @@ void get_exit_signal() { // get SIGINT or SIGTERM signal void get_sub_exit() { // catch child process exit if (EXITING) { - log_debug("Skip SIGCHLD signal"); + log_debug("Skip handle SIGCHLD"); return; } int status; - log_debug("Handle SIGCHLD begin"); + log_debug("Start handle SIGCHLD"); for (process **proc = process_list; *proc != NULL; ++proc) { if ((*proc)->pid == 0) { continue; // skip not running process