Skip to content

Commit

Permalink
chore(docker): ignore rust toolchain in docker builds
Browse files Browse the repository at this point in the history
This commit adds the known names of the rust-toolchain files to the
.dockerignore file. This has three reasons why it makes sense:

- The initial docker layer already has a set up rust toolchain that is
  sufficient to build the project. Thus, by providing a toolchain file,
  the toolchain would be installed again during docker build.
- Currently cargo-chef only copies the toolchain files during cooking
  but it gets not used during the building of the dependencies in the
  cook call, see
  LukeMathWalker/cargo-chef#271.
  With this in mind, currently the dependencies were actually build
  twice. Once with the installed toolchain from the image itself, and
  then in the actual cargo build call with the toolchain speciefied in
  the toolchain file. Building them twice resulted in timeouts when
  building the arm64 images as they are emulated using qemu, which is
  itself already slower than building natively.

Now one could argue, that as soon as the mentioned issue is solved using
the toolchain again would be fine. But then it would be still needed to
assemble the Dockerfile in a way that the toolchain is not build twice.
Because the current structure of the Dockerfile builds the toolchain
once in the cargo-chef prepare step and once during the cargo build step
(and would later build it during the cargo-chef cook instead of cargo
build).

With all this in mind using no toolchain file but instead just using
the sufficient rust installation from the base image makes sense.
  • Loading branch information
LtdSauce committed Oct 11, 2024
1 parent da1cb61 commit 7b1bf94
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ LICENSE
rustfmt.toml
_config.yml
.lycheeignore

# Ignore rust toolchain files as they would needlessly fetch the toolchain.
# But the image already contains a sufficient toolchain.
# Ignore both the latest naming and the legacy naming
rust-toolchain.toml
rust-toolchain

0 comments on commit 7b1bf94

Please sign in to comment.