Skip to content

add Dockerfile technical reference #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/development/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,52 @@ 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://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.

#### 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" .
```