FROM python:3.13-alpine AS build-rust

# install rust environment (for rant)
ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo PATH=/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUST_VERSION=1.61.0
RUN --mount=type=cache,target=/var/cache/apk apk add --update-cache rustup gcc musl-dev rsync
RUN rustup-init -y --profile minimal

# install rant
RUN --mount=type=cache,target=/root/.cargo \
    --mount=type=cache,target=/usr/local/cargo/git/db \
    --mount=type=cache,target=/usr/local/cargo/registry \
    cargo install --color=never rant --version 4.0.0-alpha.33 --root /opt/rant --features cli

FROM python:3.13-alpine AS buildenv
ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo PATH=/opt/rant/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RUST_VERSION=1.61.0
COPY --from=build-rust /opt/rant /opt/rant