From 44b5be6698df103c258b89f51031d74d967ac2e0 Mon Sep 17 00:00:00 2001 From: "mn.albeschenko" Date: Sun, 17 Dec 2023 18:21:33 +0300 Subject: [PATCH 1/3] add Dockerfile technical reference --- src/development/intro.md | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/development/intro.md b/src/development/intro.md index 761894c..801defe 100644 --- a/src/development/intro.md +++ b/src/development/intro.md @@ -43,3 +43,48 @@ scoop install mask A maskfile is self-documenting, because it is written in Markdown. You can view the maskfile [here](https://github.com/rustic-rs/rustic/blob/main/maskfile.md). + +## Dockerfile technical reference + +We utilize multistage docker build with following stages + +- `chef` - utility step to shorten code +- `planner` - analyze the current project to determine the minimum subset of files (`Cargo.lock` and `Cargo.toml` manifests) required to build it +- `builder` - consists of 2 container layers + - first - contains build dependencies (it wii be rebuild only if Cargo.lock or Cargo.toml has changes) + - second - main build of our application +- `runtime` - debian slim image for running our app (we don't use alpine cause [this](https://andygrove.io/2020/05/why-musl-extremely-slow/)) + +### `cargo-chef` + +We utilize `chef` to cache the dependencies of Rust project and speed up Docker builds. + +#### Installation + +Locally + +```bash +cargo install cargo-chef --locked +``` + +Dockerfile + +```bash +FROM lukemathwalker/cargo-chef:latest-rust-1.70.0 AS chef +``` + +#### Usage + +In Dockerfile we used `ARG` to lock `rust` version. (By default = `1.70.0`). + +When `rust` version is updated, you need to either update the standard version + +```bash +ARG RUST_VERSION=1.70.0 +``` + +or use the build argument + +```bash +docker build --build-arg="RUST_VERSION=1.70.0" . +``` From f1945eb8df6416254ab105ee7d9a804594d80b19 Mon Sep 17 00:00:00 2001 From: simonsan <14062932+simonsan@users.noreply.github.com> Date: Wed, 20 Dec 2023 01:37:25 +0100 Subject: [PATCH 2/3] Update src/development/intro.md --- src/development/intro.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/development/intro.md b/src/development/intro.md index 801defe..1b6a613 100644 --- a/src/development/intro.md +++ b/src/development/intro.md @@ -53,7 +53,7 @@ We utilize multistage docker build with following stages - `builder` - consists of 2 container layers - first - contains build dependencies (it wii be rebuild only if Cargo.lock or Cargo.toml has changes) - second - main build of our application -- `runtime` - debian slim image for running our app (we don't use alpine cause [this](https://andygrove.io/2020/05/why-musl-extremely-slow/)) +- `runtime` - debian slim image for running our app (we don't use alpine cause [this](https://web.archive.org/web/20231214004214/https://andygrove.io/2020/05/why-musl-extremely-slow/)) ### `cargo-chef` From aff98728e0121a1ac68eeb2c7d0c27f9c4efd700 Mon Sep 17 00:00:00 2001 From: "mn.albeschenko" Date: Wed, 20 Dec 2023 17:47:23 +0300 Subject: [PATCH 3/3] dprint format --- src/development/intro.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/development/intro.md b/src/development/intro.md index 1b6a613..8275418 100644 --- a/src/development/intro.md +++ b/src/development/intro.md @@ -49,15 +49,19 @@ the maskfile [here](https://github.com/rustic-rs/rustic/blob/main/maskfile.md). We utilize multistage docker build with following stages - `chef` - utility step to shorten code -- `planner` - analyze the current project to determine the minimum subset of files (`Cargo.lock` and `Cargo.toml` manifests) required to build it +- `planner` - analyze the current project to determine the minimum subset of + files (`Cargo.lock` and `Cargo.toml` manifests) required to build it - `builder` - consists of 2 container layers - - first - contains build dependencies (it wii be rebuild only if Cargo.lock or Cargo.toml has changes) + - first - contains build dependencies (it wii be rebuild only if Cargo.lock or + Cargo.toml has changes) - second - main build of our application -- `runtime` - debian slim image for running our app (we don't use alpine cause [this](https://web.archive.org/web/20231214004214/https://andygrove.io/2020/05/why-musl-extremely-slow/)) +- `runtime` - debian slim image for running our app (we don't use alpine cause + [this](https://web.archive.org/web/20231214004214/https://andygrove.io/2020/05/why-musl-extremely-slow/)) ### `cargo-chef` -We utilize `chef` to cache the dependencies of Rust project and speed up Docker builds. +We utilize `chef` to cache the dependencies of Rust project and speed up Docker +builds. #### Installation