# Leveraging the pre-built Docker images with
# cargo-chef and the Rust toolchain
FROM git.kemitix.net/kemitix/rust:v4.2.0 AS chef
WORKDIR /app
FROM chef AS planner
COPY Cargo.toml ./
COPY src src
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --all-features --profile release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin git-next --all-features && strip target/release/git-next
FROM chef AS runtime
WORKDIR /app
USER 1000
COPY --from=builder /app/target/release/git-next /usr/local/bin
ENV HOME=/app
ENTRYPOINT [ "/usr/local/bin/git-next" ]
CMD [ "server", "start" ]