From 9fafaf10922904ff79f690d81d2fbc245aa14827 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 2 Nov 2022 18:58:25 +0800 Subject: [PATCH] build: separate to-json compile --- Dockerfile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 99ae234..4a1c145 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,16 +38,21 @@ RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.VersionString=${DN COPY --from=upx /tmp/upx /usr/bin/ RUN upx -9 /tmp/dnsproxy -FROM ${RUST} AS cleardns -RUN apk add build-base cmake -COPY ./ /ClearDNS/ -WORKDIR /ClearDNS/src/to-json/ +FROM ${RUST} AS to-json +# TODO: update crates.io index +COPY ./src/to-json/ /to-json/ +WORKDIR /to-json/ RUN cargo build --release -WORKDIR /ClearDNS/bin/ +WORKDIR ./target/release/ +RUN cp libto_json.a / + +FROM ${ALPINE} AS cleardns +RUN apk add build-base cmake +COPY ./ /cleardns/ +COPY --from=to-json /libto_json.a /cleardns/src/to-json/target/release/ +WORKDIR /cleardns/bin/ RUN cmake -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_BUILD_TYPE=Release .. && make RUN strip cleardns && mv cleardns /tmp/ -COPY --from=upx /tmp/upx /usr/bin/ -RUN upx -9 /tmp/cleardns FROM ${ALPINE} AS build RUN apk add xz