moby / moby/buildkit

dockerfile: avoid accessing context local if unused

Open
#3,267 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/dockerfile help wanted kind/enhancement
Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the frontend path around Dockerfile2LLB and trace how .dockerignore is loaded before the Dockerfile is processed. Confirm where build-context file requests are made. Done means a Dockerfile that uses no context files does not load or capture the local context, while builds that request context files still load .dockerignore correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, dockerfile, go
Domain
build-system, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.