Project rebuilds from scratch on every push. Why?

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:

Hi, our balena-rust-hello-world example project was updated recently. Can you try to update your Dockerfile with the recent changes we have made?

Thanks! I’ll give that a try.

Also there were some changes on our builders -> so the modify-uname.sh hack is no longer necessary, etc. Try to reuse this updated Dockerfile.template and let us know.

Those changes did the trick. Thank you.

Glad it did help!