FROM rust:1.64.0-alpine AS builder
RUN apk add --update musl-dev
WORKDIR /home/src
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
COPY src/main.rs src/main.rs
RUN cargo fetch --locked --target x86_64-unknown-linux-musl
COPY . .
RUN cargo build --locked --target x86_64-unknown-linux-musl --release
FROM alpine:latest AS cli
ARG GITHUB_PATH=arttet/git-conventional-commits
LABEL org.opencontainers.image.source https://github.com/${GITHUB_PATH}
WORKDIR /root/
COPY --from=builder /home/src/target/x86_64-unknown-linux-musl/release/git-conventional-commits .
ENTRYPOINT ["./git-conventional-commits"]