# Builds an image containing the binary and little else.
# Builder image, with openssl added for native-tls, and initial project for Cargo.* deps to build in
FROM docker.io/library/rust:slim
RUN apt-get update \
&& apt-get install -y libssl-dev pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives \
&& cargo --version \
&& cargo install cargo-build-deps \
&& cd / \
&& cargo new --bin originz
# Build dependencies on their own as separate step to improve cached builds
# (only copy Cargo.* to avoid source changes breaking this cache)
COPY Cargo.toml Cargo.lock /originz
RUN cd /originz && cargo build-deps --release
COPY . /originz
RUN cd /originz && cargo build --release
# Release image: copy executable from builder
# Debian version needs to match builder image to avoid linker issues.
FROM docker.io/library/debian:bullseye-slim
RUN apt-get update \
&& apt-get install -y ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives
COPY --from=0 /originz/target/release/originz /originz
RUN chmod +x /originz && /originz --version