FROM alpine:edge AS builder

USER root
RUN apk add --no-cache cargo

COPY Cargo.toml /src/
COPY Cargo.lock /src/
COPY src/ /src/src
WORKDIR /src/
RUN cargo build --release --locked

# start in a clean alpine so that we don't include the crates.io registry and other large
# files in the final image
# we'll use edge, (a) because we used it before, and (b) because it usually has the most
# recent version of rust/cargo
FROM alpine:edge

RUN apk add --no-cache cargo
COPY --from=builder /src/target/release/cargo-doc2readme /usr/bin/
