Crates.io | cargo-bdeps |
lib.rs | cargo-bdeps |
version | 0.1.7 |
source | src |
created_at | 2020-06-18 17:05:09.197453 |
updated_at | 2020-07-07 19:54:56.851086 |
description | A cargo subcommand to build dependencies, helps speed up docker builds by allowing dependencies to be built earlier and cached. |
homepage | |
repository | https://github.com/nacardin/cargo-build-deps |
max_upload_size | |
id | 255389 |
size | 28,693 |
This tool extends Cargo to allow you to build only the dependencies in a given rust project. This is useful for docker builds where each build step is cached. The time it takes to build dependencies is often a significant portion of the overall build time. Therefore it is beneficial in docker builds to build dependencies in a separate step earlier than the main build. Since the dependency building step will be cached, dependencies will not need to be rebuilt when the project's own source code changes.
Inspired by (http://atodorov.org/blog/2017/08/30/speeding-up-rust-builds-inside-docker/)
cargo install cargo-build-deps
cargo build-deps
Change Dockerfile from
FROM rust:1.23 as rust-builder
RUN mkdir /tmp/PROJECT_NAME
WORKDIR /tmp/PROJECT_NAME
COPY . .
RUN cargo build --release
to
FROM rust:1.23 as rust-builder
RUN cargo install cargo-build-deps
RUN cd /tmp && USER=root cargo new --bin PROJECT_NAME
WORKDIR /tmp/PROJECT_NAME
COPY Cargo.toml Cargo.lock ./
RUN cargo build-deps --release
COPY src /tmp/PROJECT_NAME/src
RUN cargo build --release
Licensed under either of these:
Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in the work, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.