Browse Source

build: cleardns rust modules

dev
Dnomd343 2 years ago
parent
commit
657fef1dc0
  1. 4
      CMakeLists.txt
  2. 24
      Dockerfile

4
CMakeLists.txt

@ -14,10 +14,6 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
if(NOT CMAKE_EXE_LINKER_FLAGS)
set(CMAKE_EXE_LINKER_FLAGS -static)
endif()
############################################################### ###############################################################
macro(git_tag _tag) macro(git_tag _tag)

24
Dockerfile

@ -1,5 +1,5 @@
ARG ALPINE="alpine:3.17" 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" ARG GOLANG="golang:1.18-alpine3.16"
FROM ${ALPINE} AS upx 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/ COPY --from=upx /tmp/upx /usr/bin/
RUN upx -9 /tmp/dnsproxy RUN upx -9 /tmp/dnsproxy
FROM ${RUST} AS to-json FROM ${RUST} AS rust-mods
COPY ./src/to-json/ /to-json/ RUN apk add libc-dev openssl-dev
WORKDIR /to-json/ COPY ./src/ /cleardns/
RUN cargo build --release WORKDIR /cleardns/
RUN cp ./target/release/libto_json.a / RUN cargo fetch
RUN cargo build --release && mv ./target/release/*.a /tmp/
FROM ${ALPINE} AS cleardns FROM ${ALPINE} AS cleardns
RUN apk add build-base cmake RUN apk add build-base cmake git openssl-libs-static
COPY ./ /cleardns/ 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/ WORKDIR /cleardns/bin/
RUN cmake -DCMAKE_EXE_LINKER_FLAGS=-static -DCMAKE_BUILD_TYPE=Release .. && make RUN cmake -DCMAKE_EXE_LINKER_FLAGS=-static .. && make && mv cleardns /tmp/
RUN strip cleardns && mv cleardns /tmp/
COPY --from=upx /tmp/upx /usr/bin/ COPY --from=upx /tmp/upx /usr/bin/
RUN upx -9 /tmp/cleardns WORKDIR /tmp/
RUN strip cleardns && upx -9 cleardns
FROM ${ALPINE} AS build FROM ${ALPINE} AS build
RUN apk add xz RUN apk add xz

Loading…
Cancel
Save