I am using inline caching with my docker image. When running docker build locally, the cache is always used. In my pipelines, the behavior is inconsistent and usually results in the entire dockerfile building from scratch. I have not been able to figure out where the problem is.
This is the start of the dockerfile:
# syntax = docker/dockerfile:1.2
# Dockerfile for customer container for Lambdas.
# Author: Boris K., 2022.07.27
# ERB-2638
FROM --platform=linux/amd64 public.ecr.aws/lambda/python:3.12.2024.05.22.12@sha256:8b72b07c4eeba48a87799c6357ddf3d0abbd28dd3e0ead220427839cd160121f
RUN dnf install awscli \
gzip \
wget \
tar \
sudo \
unzip \
xorg-x11-fonts-* \
which \
cargo \
# below are needed the deps for LibreOffice
libXinerama \
java \
nss \
dbus-libs \
cups-libs \
-y && dnf clean all
Does anyone know why this first FROM command might pull from cache sometimes, but usually not? The layer should not be changing and the SHA is always the same. That is a static layer provided by AWS. So why would caching always work locally, but not in Bitbucket pipelines?
The command I am using for docker build is:
DOCKER_BUILDKIT=1 DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build . -t my_image:latest -f dockerfile --cache-from my_image:latest --build-arg BUILDKIT_INLINE_CACHE=1