mirror of https://github.com/dnomd343/ClearDNS
dnomd343
2 years ago
1 changed files with 52 additions and 62 deletions
@ -1,71 +1,61 @@ |
|||||
FROM golang:1.18-alpine3.16 AS adguardhome |
ARG ALPINE_IMG="alpine:3.16" |
||||
ENV ADGUARD_VERSION="v0.107.8" |
ARG GOLANG_IMG="golang:1.18-alpine3.16" |
||||
RUN \ |
|
||||
apk add git make npm yarn && \ |
|
||||
git clone https://github.com/AdguardTeam/AdGuardHome.git && \ |
|
||||
cd ./AdGuardHome/ && git checkout ${ADGUARD_VERSION} && \ |
|
||||
make CHANNEL="release" VERSION=${ADGUARD_VERSION} && \ |
|
||||
mv ./AdGuardHome /tmp/ |
|
||||
|
|
||||
FROM golang:1.18-alpine3.16 AS dnsproxy |
FROM ${ALPINE_IMG} AS upx |
||||
ENV DNSPROXY_VERSION="v0.43.1" |
ENV UPX_VER="3.96" |
||||
RUN \ |
RUN sed -i 's/v3.\d\d/v3.15/' /etc/apk/repositories && apk add bash build-base perl ucl-dev zlib-dev |
||||
apk add git && \ |
RUN wget https://github.com/upx/upx/releases/download/v${UPX_VER}/upx-${UPX_VER}-src.tar.xz && tar xf upx-${UPX_VER}-src.tar.xz |
||||
git clone https://github.com/AdguardTeam/dnsproxy.git && \ |
WORKDIR ./upx-${UPX_VER}-src/ |
||||
cd ./dnsproxy/ && git checkout ${DNSPROXY_VERSION} && \ |
RUN make -C ./src/ && mkdir -p /upx/bin/ && mv ./src/upx.out /upx/bin/upx && \ |
||||
env CGO_ENABLED=0 go build -trimpath \ |
mkdir -p /upx/lib/ && cd /usr/lib/ && cp -d ./libgcc_s.so* ./libstdc++.so* ./libucl.so* /upx/lib/ |
||||
-ldflags "-X main.VersionString=${DNSPROXY_VERSION} -s -w" && \ |
|
||||
mv ./dnsproxy /tmp/ |
|
||||
|
|
||||
FROM golang:1.18-alpine3.16 AS overture |
FROM ${GOLANG_IMG} AS adguardhome |
||||
ENV OVERTURE_VERSION="v1.8" |
ENV ADGUARD_VER="v0.107.12" |
||||
RUN \ |
RUN apk add git make npm yarn |
||||
apk add git && \ |
RUN git clone https://github.com/AdguardTeam/AdGuardHome.git |
||||
git clone https://github.com/shawn1m/overture.git && \ |
WORKDIR ./AdGuardHome/ |
||||
cd ./overture/ && git checkout ${OVERTURE_VERSION} && \ |
RUN git checkout ${ADGUARD_VER} && make CHANNEL="release" VERSION=${ADGUARD_VER} && mv ./AdGuardHome /tmp/ |
||||
env CGO_ENABLED=0 go build -o overture -trimpath \ |
|
||||
-ldflags "-X main.version=${OVERTURE_VERSION} -s -w" ./main/main.go && \ |
|
||||
mv ./overture /tmp/ |
|
||||
|
|
||||
# upx can't be compiled under gcc11, so we should use alpine:3.15 |
FROM ${GOLANG_IMG} AS dnsproxy |
||||
FROM alpine:3.15 AS upx |
ENV DNSPROXY_VER="0.44.0" |
||||
ENV UPX_VERSION="3.96" |
RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY_VER}.tar.gz && tar xf v${DNSPROXY_VER}.tar.gz |
||||
RUN \ |
WORKDIR ./dnsproxy-${DNSPROXY_VER}/ |
||||
apk add bash build-base perl ucl-dev zlib-dev && \ |
RUN go mod download -x |
||||
wget https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-src.tar.xz && \ |
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DNSPROXY_VER} -s -w" && mv ./dnsproxy /tmp/ |
||||
tar xf upx-${UPX_VERSION}-src.tar.xz && \ |
|
||||
cd upx-${UPX_VERSION}-src/ && make all && \ |
|
||||
mv ./src/upx.out /tmp/upx |
|
||||
|
|
||||
FROM alpine:3.16 AS cleardns |
FROM ${GOLANG_IMG} AS overture |
||||
|
ENV OVERTURE_VER="1.8" |
||||
|
RUN wget https://github.com/shawn1m/overture/archive/refs/tags/v${OVERTURE_VER}.tar.gz && tar xf ./v${OVERTURE_VER}.tar.gz |
||||
|
WORKDIR ./overture-${OVERTURE_VER}/ |
||||
|
RUN env CGO_ENABLED=0 go build -o overture -trimpath -ldflags "-X main.version=v${OVERTURE_VER} -s -w" ./main/main.go && mv ./overture /tmp/ |
||||
|
|
||||
|
FROM ${ALPINE_IMG} AS cleardns |
||||
COPY . /ClearDNS |
COPY . /ClearDNS |
||||
RUN \ |
RUN apk add build-base cmake glib-dev |
||||
apk add build-base cmake glib-dev && \ |
RUN cd ./ClearDNS/ && mkdir ./build/ && \ |
||||
cd ./ClearDNS/ && mkdir ./build/ && \ |
cd ./build/ && cmake -DCMAKE_BUILD_TYPE=Release .. && make && \ |
||||
cd ./build/ && cmake -DCMAKE_BUILD_TYPE=Release .. && make && \ |
mv ../bin/cleardns /tmp/ && strip /tmp/cleardns |
||||
mv ../bin/cleardns /tmp/ |
|
||||
|
|
||||
FROM alpine:3.16 AS asset |
FROM ${ALPINE_IMG} AS asset |
||||
COPY --from=adguardhome /tmp/AdGuardHome /release/ |
RUN apk add xz && \ |
||||
COPY --from=dnsproxy /tmp/dnsproxy /release/ |
wget https://res.dnomd343.top/Share/gfwlist/gfwlist.txt && \ |
||||
COPY --from=overture /tmp/overture /release/ |
wget https://res.dnomd343.top/Share/chinalist/china-ip.txt && \ |
||||
COPY --from=cleardns /tmp/cleardns /release/ |
wget https://res.dnomd343.top/Share/chinalist/chinalist.txt && \ |
||||
COPY --from=upx /tmp/upx /usr/bin/ |
tar cJf /tmp/assets.tar.xz ./gfwlist.txt ./china-ip.txt ./chinalist.txt |
||||
|
COPY --from=dnsproxy /tmp/dnsproxy /asset/usr/bin/ |
||||
|
COPY --from=overture /tmp/overture /asset/usr/bin/ |
||||
|
COPY --from=adguardhome /tmp/AdGuardHome /asset/usr/bin/ |
||||
|
COPY --from=upx /upx/ /usr/ |
||||
|
RUN ls /asset/usr/bin/* | xargs -P0 -n1 upx -9 |
||||
|
COPY --from=cleardns /tmp/cleardns /asset/usr/bin/ |
||||
COPY . /ClearDNS |
COPY . /ClearDNS |
||||
RUN \ |
RUN mkdir -p /asset/etc/ && \ |
||||
apk add gcc ucl && \ |
cp -r /ClearDNS/overture/ /asset/etc/ && \ |
||||
cd /release/ && strip cleardns && \ |
mv /tmp/assets.tar.xz /asset/etc/overture/asset.tar.xz && \ |
||||
upx -9 AdGuardHome dnsproxy overture && \ |
mv /ClearDNS/load.sh /asset/usr/bin/load |
||||
wget https://res.dnomd343.top/Share/gfwlist/gfwlist.txt && \ |
|
||||
wget https://res.dnomd343.top/Share/chinalist/chinalist.txt && \ |
|
||||
wget https://res.dnomd343.top/Share/chinalist/china-ip.txt && \ |
|
||||
tar czf asset.tar.gz gfwlist.txt chinalist.txt china-ip.txt && rm -f *.txt && \ |
|
||||
mkdir -p /asset/etc/ && mkdir -p /asset/usr/ && \ |
|
||||
cp -r /ClearDNS/overture/ /asset/etc/ && mv asset.tar.gz /asset/etc/overture/ && \ |
|
||||
mv /release/ /asset/usr/bin/ && mv /ClearDNS/load.sh /asset/usr/bin/load |
|
||||
|
|
||||
FROM alpine:3.16 |
FROM ${ALPINE_IMG} |
||||
COPY --from=asset /asset / |
COPY --from=asset /asset / |
||||
RUN apk add --no-cache ca-certificates glib iptables ip6tables && \ |
RUN #apk add --no-cache ca-certificates glib && \ |
||||
echo -e "0\t4\t*\t*\t*\t/etc/overture/update.sh" > /var/spool/cron/crontabs/root |
#echo -e "0\t4\t*\t*\t*\t/etc/overture/update.sh" > /var/spool/cron/crontabs/root |
||||
ENTRYPOINT ["cleardns"] |
#ENTRYPOINT ["cleardns"] |
||||
|
Loading…
Reference in new issue