Recently I’ve noticed our build is generating very big deltas even when all of the significant steps are cached. For example, in my most recently build I changed something in one service (nautilus) and the container build for a different service (nemo) resulted in a 35 MB delta size.
The nemo build used previously cached data for all of the layers that contain actual content:
... [nemo] Step 6/9 : RUN pip install --user -r logunitas/requirements-s3-uploader.txt [nemo] Using cache [nemo] ---> b44d05c15af6 [nemo] Step 7/9 : COPY version.txt ./nemo/ [nemo] ---> ea72cbb480fb [nemo] Step 8/9 : WORKDIR /home/point_one/nemo [nemo] ---> Running in 9f43b598a148 [nemo] Removing intermediate container 9f43b598a148 [nemo] ---> 9ed664c1bbfb [nemo] Step 9/9 : CMD ["python3", "-m", "nautilus.nemo", "--nemo-host=0.0.0.0", "balena"] [nemo] ---> Running in 1e3a41219532 [nemo] Removing intermediate container 1e3a41219532 [nemo] ---> df3e2605c019 [nemo] Successfully built df3e2605c019 ... [Info] Release: 191c3b0d45300662c654cb5f545dad01 (id: 1517226) [Info] ┌─────────────┬────────────┬────────────┬────────────┐ [Info] │ Service │ Image Size │ Delta Size │ Build Time │ [Info] ├─────────────┼────────────┼────────────┼────────────┤ ... [Info] │ nemo │ 261.13 MB │ 34.72 MB │ 12 seconds │
Note that updating either service updates a very small
version.txt file, which is copied into each container as one of the last steps in the Dockerfile, so it shouldn’t invalidate the previous steps with the actual code.
The only steps that were actually executed for nemo were
COPY of single
version.txt text file (25 B),
CMD. I would have expected the delta for this update to nemo to be very small.