Browse Source

build: update docker build

dev
dnomd343 2 years ago
parent
commit
5ad130b650
  1. 47
      Dockerfile

47
Dockerfile

@ -1,5 +1,7 @@
ARG ALPINE_IMG="alpine:3.16"
ARG GOLANG_IMG="golang:1.18-alpine3.16"
ARG ALPINE_VER="3.16"
ARG GOLANG_VER="1.18"
ARG ALPINE_IMG="alpine:${ALPINE_VER}"
ARG GOLANG_IMG="golang:${GOLANG_VER}-alpine${ALPINE_VER}"
FROM ${ALPINE_IMG} AS upx
ENV UPX_VER="3.96"
@ -15,39 +17,50 @@ RUN apk add git make npm yarn && git clone https://github.com/AdguardTeam/AdGuar
WORKDIR ./AdGuardHome/
RUN git checkout ${ADGUARD_VER} && make js-deps
RUN make js-build
RUN make CHANNEL="release" VERSION=${ADGUARD_VER} VERBOSE=1 go-build && mv ./AdGuardHome /tmp/
RUN make CHANNEL="release" VERSION=${ADGUARD_VER} VERBOSE=1 go-build && mv AdGuardHome /tmp/
COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/AdGuardHome
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}/main/
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=v${OVERTURE_VER} -s -w" && mv main /tmp/overture
COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/overture
FROM ${GOLANG_IMG} AS dnsproxy
ENV DNSPROXY_VER="0.44.0"
RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY_VER}.tar.gz && tar xf v${DNSPROXY_VER}.tar.gz
WORKDIR ./dnsproxy-${DNSPROXY_VER}/
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DNSPROXY_VER} -s -w" && mv ./dnsproxy /tmp/
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DNSPROXY_VER} -s -w" && mv dnsproxy /tmp/
COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/dnsproxy
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}/main/
RUN env CGO_ENABLED=0 go build -o overture -trimpath -ldflags "-X main.version=v${OVERTURE_VER} -s -w" ./main.go && mv ./overture /tmp/
FROM ${GOLANG_IMG} AS toJSON
COPY ./toJSON/ /toJSON/
WORKDIR /toJSON/
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv toJSON /tmp/
COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/toJSON
FROM ${ALPINE_IMG} AS cleardns
RUN apk add build-base cmake
#COPY . /ClearDNS
RUN touch /tmp/cleardns
#RUN cd ./ClearDNS/ && mkdir ./build/ && \
# cd ./build/ && cmake -DCMAKE_BUILD_TYPE=Release .. && make && \
# mv ../bin/cleardns /tmp/ && strip /tmp/cleardns
COPY ./ /ClearDNS/
WORKDIR /ClearDNS/build/
RUN cmake -DCMAKE_BUILD_TYPE=Release .. && make && mv ../bin/cleardns /tmp/ && strip /tmp/cleardns
COPY --from=toJSON /tmp/toJSON /tmp/
FROM ${ALPINE_IMG} AS asset
COPY --from=upx /upx/ /usr/
COPY --from=dnsproxy /tmp/dnsproxy /asset/usr/bin/
COPY --from=overture /tmp/overture /asset/usr/bin/
COPY --from=adguardhome /tmp/AdGuardHome /asset/usr/bin/
RUN ls /asset/usr/bin/* | xargs -P0 -n1 upx -9
RUN wget https://res.dnomd343.top/Share/gfwlist/gfwlist.txt && \
wget https://res.dnomd343.top/Share/chinalist/china-ip.txt && \
wget https://res.dnomd343.top/Share/chinalist/chinalist.txt
RUN apk add xz && tar cJf /asset/assets.tar.xz ./gfwlist.txt ./china-ip.txt ./chinalist.txt
RUN apk add xz && tar cJf /asset/assets.tar.xz ./*.txt
COPY --from=cleardns /tmp/cleardns /asset/usr/bin/
COPY --from=cleardns /tmp/toJSON /asset/usr/bin/
FROM ${ALPINE_IMG}
COPY --from=asset /asset/ /

Loading…
Cancel
Save