diff --git a/CMakeLists.txt b/CMakeLists.txt index 0699993..d93e542 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,6 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() -if(NOT CMAKE_EXE_LINKER_FLAGS) - set(CMAKE_EXE_LINKER_FLAGS -static) -endif() - ############################################################### macro(git_tag _tag) diff --git a/Dockerfile b/Dockerfile index 5fab6de..b90bfac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG ALPINE="alpine:3.17" -ARG RUST="rust:1.65-alpine3.16" +ARG RUST="rust:1.67-alpine3.17" ARG GOLANG="golang:1.18-alpine3.16" FROM ${ALPINE} AS upx @@ -38,21 +38,23 @@ 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 to-json -COPY ./src/to-json/ /to-json/ -WORKDIR /to-json/ -RUN cargo build --release -RUN cp ./target/release/libto_json.a / +FROM ${RUST} AS rust-mods +RUN apk add libc-dev openssl-dev +COPY ./src/ /cleardns/ +WORKDIR /cleardns/ +RUN cargo fetch +RUN cargo build --release && mv ./target/release/*.a /tmp/ FROM ${ALPINE} AS cleardns -RUN apk add build-base cmake +RUN apk add build-base cmake git openssl-libs-static COPY ./ /cleardns/ -COPY --from=to-json /libto_json.a /cleardns/src/to-json/target/release/ +COPY --from=rust-mods /tmp/libassets.a /cleardns/src/target/release/ +COPY --from=rust-mods /tmp/libto_json.a /cleardns/src/target/release/ WORKDIR /cleardns/bin/ -RUN cmake -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_BUILD_TYPE=Release .. && make -RUN strip cleardns && mv cleardns /tmp/ +RUN cmake -DCMAKE_EXE_LINKER_FLAGS=-static .. && make && mv cleardns /tmp/ COPY --from=upx /tmp/upx /usr/bin/ -RUN upx -9 /tmp/cleardns +WORKDIR /tmp/ +RUN strip cleardns && upx -9 cleardns FROM ${ALPINE} AS build RUN apk add xz