This updates #4270 to add an integration test and also merge some of the
logic for how the selectors are created. Now, `toSelectors` will perform
the root path detection instead of some custom logic in `getMountDeps`.
`dedupePaths` has also been updated to check if the number of paths is 1
or less so it can avoid an allocation when the function is a no-op.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
When a step in the dockerfile is a dependency of multiple other steps in
the dockerfile, the provenance attestation would record the layer chain
for that step multiple times even with the same layer chain.
This is because the provenance attestation reuses the exporter mechanic
and the exporter mechanic would need to visit this same step multiple
times to produce the appropriate cache entries.
Since these duplicate layer chains aren't intentional, this modifies the
provenance attestation capture to detect these duplicates and remove
them.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Trivially created by looking for every reference to .Variant and adding
OSVersion and OSFeatures, except the ones related to the string
representation of a Platform instance.
I then went through and ensured every assignment of OSFeatures that
might leak out, i.e., not local-only or for marhsalling purposes, uses
the append-to-nil idiom to avoid sharing the slice storage and allowing
accidental mutation after-the-fact.
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
The build target is not quoted and it makes it difficult for some
persons to see what the problem is.
By quoting it we emphasize that the target name is variable.
Signed-off-by: Frank Villaro-Dixon <frank.villarodixon@merkle.com>
Review comments and edge cases
- the `${}` parser handles escapes, but needs to preserve them for `#`/`%`
- but `\}` needs to be de-escaped
- reversing strings need to handle escapes, i.e. `a\*c` -> `c\*a`
- build the regex with a scanner, not QuoteMeta+StringReplace
- add more complicated cases to the tests
Separate out + unit test helper functions
Add trim test to dockerfile_test
Signed-off-by: Tristan Stenner <ts@ppi.de>
This allows callers to pass in a non-default build context without
creating and passing in a dockerui.Client.
Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
.dockerignore relates more to build context than to the Dockerfile
frontend, so it makes more sense to document the syntax for this file
where we describe how build contexts work.
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
rewrite-timestamp rewrites timestamps in layers for reproducible
builds.
When a layer is rewritten, an annotation "buildkit/rewritten-timestamp=<INT64>"
is set to the layer.
Example:
```
buildctl build
--frontend dockerfile.v0 \
--opt build-arg:SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
--output type=oci,dest=dest.tar,rewrite-timestamp=true \
...
```
Alternative to PR 3560
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Previously, we would panic on marshalling when attempting to use
./examples/dockerfile2llb to print a target. This was because no client
was available to call MainContext.
Signed-off-by: Justin Chadwell <me@jedevc.com>
The "reference" package was moved to a separate module, which was extracted
from b9b19409cf
Also updating docker/docker, which also switched to this new module;
vendor: github.com/docker/docker 032797ea4bcb (v25.0.0-dev)
full diff: afd4805278...032797ea4b
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
If build contains multiple subbuilds all of their sources
are tracked in provenance attestations. When some subbuilds
are coming from same source file (eg. same Dockerfile but
different targets) currently the same file would appear
in multiple times. This detects such duplicates and makes
sure definitions from multiple subbuilds can map to same file.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This package was moved to github.com/moby/patternmatcher/ignorefile.
Mark the alias as deprecated.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The BuildKit dockerignore package was integrated in the patternmatcher
repository / module. This patch updates our uses of the BuildKit package
with its new location.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This patch splits up the integration test package down into several
parts, the core integration helpers, the buildkit test workers and
various test helpers.
With this, we can split the worker features off as well, which improves
the general reusability of the package, so we can create our own custom
features in buildx where we reuse this package.
Signed-off-by: Justin Chadwell <me@jedevc.com>
ADD --checksum and git url graduated in v1.6,
removing the references to labs channel since
they are now in stable.
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
Errors from Tmpdir are always passed as an argument to require.NoError,
so we can instead move this error check to inside the helper, to avoid a
few extra lines in tests that call it.
Signed-off-by: Justin Chadwell <me@jedevc.com>
While this function would usually be used for read a `.dockerignore` file,
it accepts a Reader and can also be used to handle ignore patterns from
other files (e.g. `Dockerfile.dockerignore`) or other sources. The error
was also wrapped multiple times in some code-paths, which could lead to
an error being formatted as:
failed to parse dockerignore: error reading .dockerignore: <some error>
Let's remove mention of the `.dockerignore` filename from the error, and
leave it to the caller to include the filename.
This patch also brings the MainContext dockerignore error inline with the
NamedContext dockerignore error, now printing the exact name of the file.
Co-authored-by: Justin Chadwell <me@jedevc.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
- don't use a temp-file for the test as all we need is a reader
- use a const and string-literal for the test-content, which makes it
slightly more readable
- don't use hard-coded tests for each line, but use an "expected" slice
- don't fail early if line-numbers don't match
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
We can't avoid squashing even after just fixing up whiteout timestamps;
Squashing is still needed to apply the `touch`-ed timestamps across multiple `RUN` instructions.
Squashing will no longer be needed if we can merge PR 3560.
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Unlike .gitignore, `*.md` in .dockerignore doesn't match
`subdir/foo.md`. While the logic is in github.com/moby/patternmatcher,
it is worth to note the difference in the reference document.
Signed-off-by: Kazuyoshi Kato <kaz@fly.io>
This ensures that files with '%' and '+' can still be properly copied.
To prevent regressions, this also adds in a couple of example test
cases.
Signed-off-by: Justin Chadwell <me@jedevc.com>