Browse Source

build: docker arguments

dev
Dnomd343 2 years ago
parent
commit
56144afe9c
  1. 66
      Dockerfile

66
Dockerfile

@ -1,67 +1,67 @@
ARG ALPINE_IMG="alpine:3.16" ARG ALPINE="alpine:3.16"
ARG GOLANG_IMG="golang:1.18-alpine3.16" ARG GOLANG="golang:1.18-alpine3.16"
FROM ${ALPINE_IMG} AS upx FROM ${ALPINE} AS upx
ENV UPX_VER="3.96" ENV UPX="3.96"
RUN sed -i 's/v3.\d\d/v3.15/' /etc/apk/repositories && apk add bash build-base perl ucl-dev zlib-dev RUN sed -i 's/v3.\d\d/v3.15/' /etc/apk/repositories && apk add bash build-base perl ucl-dev zlib-dev
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 RUN wget https://github.com/upx/upx/releases/download/v${UPX}/upx-${UPX}-src.tar.xz && tar xf upx-${UPX}-src.tar.xz
WORKDIR ./upx-${UPX_VER}-src/ WORKDIR ./upx-${UPX}-src/
RUN make -C ./src/ && mkdir -p /upx/bin/ && mv ./src/upx.out /upx/bin/upx && \ RUN make -C ./src/ && mkdir -p /upx/bin/ && mv ./src/upx.out /upx/bin/upx && \
mkdir -p /upx/lib/ && cd /usr/lib/ && cp -d ./libgcc_s.so* ./libstdc++.so* ./libucl.so* /upx/lib/ mkdir -p /upx/lib/ && cd /usr/lib/ && cp -d libgcc_s.so* libstdc++.so* libucl.so* /upx/lib/
FROM ${GOLANG_IMG} AS adguard FROM ${GOLANG} AS adguard
ENV ADGUARD_VER="v0.107.14" ENV ADGUARD="v0.107.14"
RUN apk add git make npm yarn && git clone https://github.com/AdguardTeam/AdGuardHome.git RUN apk add git make npm yarn && git clone https://github.com/AdguardTeam/AdGuardHome.git
WORKDIR ./AdGuardHome/ WORKDIR ./AdGuardHome/
RUN git checkout ${ADGUARD_VER} && make js-deps RUN git checkout ${ADGUARD} && make js-deps
RUN make js-build RUN make js-build
RUN make CHANNEL="release" VERSION=${ADGUARD_VER} VERBOSE=1 go-build && mv AdGuardHome /tmp/ RUN make CHANNEL="release" VERSION=${ADGUARD} VERBOSE=1 go-build && mv AdGuardHome /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/AdGuardHome RUN upx -9 /tmp/AdGuardHome
FROM ${GOLANG_IMG} AS overture FROM ${GOLANG} AS overture
ENV OVERTURE_VER="1.8" ENV OVERTURE="1.8"
RUN wget https://github.com/shawn1m/overture/archive/refs/tags/v${OVERTURE_VER}.tar.gz && tar xf ./v${OVERTURE_VER}.tar.gz RUN wget https://github.com/shawn1m/overture/archive/refs/tags/v${OVERTURE}.tar.gz && tar xf ./v${OVERTURE}.tar.gz
WORKDIR ./overture-${OVERTURE_VER}/main/ WORKDIR ./overture-${OVERTURE}/main/
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=v${OVERTURE_VER} -s -w" && mv main /tmp/overture RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=v${OVERTURE} -s -w" && mv main /tmp/overture
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/overture RUN upx -9 /tmp/overture
FROM ${GOLANG_IMG} AS dnsproxy FROM ${GOLANG} AS dnsproxy
ENV DNSPROXY_VER="0.45.1" ENV DNSPROXY="0.45.1"
RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY_VER}.tar.gz && tar xf v${DNSPROXY_VER}.tar.gz RUN wget https://github.com/AdguardTeam/dnsproxy/archive/refs/tags/v${DNSPROXY}.tar.gz && tar xf v${DNSPROXY}.tar.gz
WORKDIR ./dnsproxy-${DNSPROXY_VER}/ WORKDIR ./dnsproxy-${DNSPROXY}/
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} -s -w" && mv dnsproxy /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/dnsproxy RUN upx -9 /tmp/dnsproxy
FROM ${GOLANG_IMG} AS toJSON FROM ${GOLANG} AS toJSON
COPY ./toJSON/ /toJSON/ COPY ./toJSON/ /toJSON/
WORKDIR /toJSON/ WORKDIR /toJSON/
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv toJSON /tmp/ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv toJSON /tmp/
COPY --from=upx /upx/ /usr/ COPY --from=upx /upx/ /usr/
RUN upx -9 /tmp/toJSON RUN upx -9 /tmp/toJSON
FROM ${ALPINE_IMG} AS cleardns FROM ${ALPINE} AS cleardns
RUN apk add build-base cmake RUN apk add build-base cmake
COPY ./ /ClearDNS/ COPY ./ /ClearDNS/
WORKDIR /ClearDNS/build/ WORKDIR /ClearDNS/build/
RUN cmake -DCMAKE_BUILD_TYPE=Release .. && make && mv ../bin/cleardns /tmp/ && strip /tmp/cleardns RUN cmake -DCMAKE_BUILD_TYPE=Release .. && make && mv ../bin/cleardns /tmp/ && strip /tmp/cleardns
FROM ${ALPINE_IMG} AS asset FROM ${ALPINE} AS build
RUN apk add xz RUN apk add xz
WORKDIR /asset/ WORKDIR /release/
RUN wget https://res.dnomd343.top/Share/cleardns/gfwlist.txt.xz && \ 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/china-ip.txt.xz && \
wget https://res.dnomd343.top/Share/cleardns/chinalist.txt.xz && \ wget https://res.dnomd343.top/Share/cleardns/chinalist.txt.xz && \
xz -d *.xz && tar cJf assets.tar.xz ./*.txt && rm *.txt xz -d *.xz && tar cJf assets.tar.xz *.txt && rm *.txt
COPY --from=dnsproxy /tmp/dnsproxy /asset/usr/bin/ COPY --from=dnsproxy /tmp/dnsproxy /release/usr/bin/
COPY --from=overture /tmp/overture /asset/usr/bin/ COPY --from=overture /tmp/overture /release/usr/bin/
COPY --from=adguard /tmp/AdGuardHome /asset/usr/bin/ COPY --from=adguard /tmp/AdGuardHome /release/usr/bin/
COPY --from=cleardns /tmp/cleardns /asset/usr/bin/ COPY --from=cleardns /tmp/cleardns /release/usr/bin/
COPY --from=toJSON /tmp/toJSON /asset/usr/bin/ COPY --from=toJSON /tmp/toJSON /release/usr/bin/
FROM ${ALPINE_IMG} FROM ${ALPINE}
COPY --from=asset /asset/ / COPY --from=build /release/ /
WORKDIR /cleardns/ WORKDIR /cleardns/
ENTRYPOINT ["cleardns"] ENTRYPOINT ["cleardns"]

Loading…
Cancel
Save