Somehow my project is not taking advantage of docker caching. The rust toolchain gets re-installed on every build, even if I only modified some code. What I am doing wrong?
The first few lines of my dockerfile are as follows:
################################################################################
# Base image
################################################################################
FROM balenalib/%%RESIN_MACHINE_NAME%%-debian:stretch-build as build
ENV DEBIAN_FRONTEND=noninteractive
################################################################################
# Rust image
################################################################################
FROM build as rust-toolchain
ENV PATH=/root/.cargo/bin:$PATH
# Modify `uname -m` for `arm7hf` and `rpi` RESIN_ARCH values:
# https://forums.resin.io/t/rustup-fails-for-armv8l/2661
# -> https://forums.resin.io/t/resin-build-variable-inconsistency/1571/2
# -> https://github.com/resin-io/docs/issues/739
# bump ---
# https://github.com/rust-lang-nursery/rustup.rs/issues/1055
WORKDIR /build
COPY scripts/modify-uname.sh .
RUN ./modify-uname.sh %%RESIN_ARCH%%
# Install rustup downloading the version specified by the standard rust-toolchain file
COPY rust-toolchain .
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain `cat rust-toolchain`
The whole Dockerfile is visible here: