# select build image
FROM rust:1.68-slim-bookworm as build
RUN DEBIAN=NONINTERACTIVE apt update; apt install -y pkg-config libssl-dev; rm -rf /var/lib/apt/lists/*
# create a new empty shell project
RUN USER=root cargo new --bin my_project
WORKDIR /my_project
# copy your source tree
COPY ./src ./src
COPY ./Cargo.toml .
COPY ./Cargo.lock .
# build for release
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo build --release
# our final base
FROM debian:bookworm-slim
# copy the build artifact from the build stage
COPY --from=build /my_project/target/release/monocle /usr/local/bin/monocle
RUN DEBIAN=NONINTERACTIVE apt update; apt install -y libssl-dev ca-certificates; rm -rf /var/lib/apt/lists/*
# have a local cache of AS information
RUN monocle whois 400644