#3267·buildkit

dockerfile: avoid accessing context local if unused

Author: tonistiigiCreated Nov 9, 2022Updated Sep 25, 2026
Labelskind/enhancementhelp wantedarea/dockerfile

While looking at some provenance attestations, I noticed that when building from local dockerfile that doesn't use anything from build context, the local source for context is still captured. This happens because the frontend always tries to read the .dockerignore file before calling Dockerfile2LLB.

We could avoid this by moving dockerignore loading into a callback for this case that is only called if there is a request to actually load any files from the build context.