FROM rust:1.61.0-slim as builder

RUN \
    apt-get update; \
    apt-get install -y libclang-dev

COPY ./src ./src
COPY ./Cargo.toml ./Cargo.toml
RUN cargo build --release
# find the excecutable
RUN mkdir ./output
RUN mv $(find ./target/release -maxdepth 1 -executable -type f) ./output/exec

FROM debian:bullseye-slim

RUN \
    apt-get update; \
    apt-get install -y --no-install-recommends wireguard iproute2; \
    rm -rf /var/lib/apt/lists/*;

COPY --from=builder ./output .

CMD ["/exec"]
