FROM alpine:edge AS alpine-edge

RUN apk upgrade --no-cache \
 && apk add --no-cache cargo

FROM alpine-edge AS builder

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/
