Git Product home page Git Product logo

cargo-build-deps's Introduction

cargo-build-deps

Build Status Crates.io

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/)

Install

cargo install cargo-build-deps

Usage

cargo build-deps

Example

Change Dockerfile from

FROM rust:1 as rust-builder
RUN mkdir /tmp/PROJECT_NAME
WORKDIR /tmp/PROJECT_NAME
COPY . .
RUN cargo build  --release

to

FROM rust:1 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

License

Licensed under either of these:

Contributing

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.

cargo-build-deps's People

Contributors

dependabot-preview[bot] avatar nacardin avatar rodoufu avatar rpsrosario avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.