Commit Graph

1249 Commits

Author SHA1 Message Date
Tõnis Tiigi
6997850e16 Merge pull request #4281 from jsternberg/duplicate-mount-integration-test
solver: use toSelectors to filter root paths instead of custom logic
2023-12-05 23:19:15 -08:00
Jonathan A. Sternberg
091fb2c80d solver: use toSelectors to filter root paths instead of custom logic
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>
2023-12-04 14:02:16 -06:00
CrazyMax
b598b52e55 Merge pull request #4421 from dvdksn/docs-refresh
docs: refresh dockerfile frontend reference
2023-11-27 02:16:45 -08:00
David Karlsson
53b4a8dae6 docs: dockerfile instructions quick reference
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2023-11-27 10:57:59 +01:00
Tõnis Tiigi
732333a25b Merge pull request #4433 from jsternberg/duplicate-provenance-layers
dockerfile: remove duplicate layer chains from provenance attestation
2023-11-22 09:58:20 -08:00
Jonathan A. Sternberg
94af8de274 dockerfile: remove duplicate layer chains from provenance attestation
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>
2023-11-22 10:17:42 -06:00
David Karlsson
9c921c6322 docs: refresh dockerfile frontend reference
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2023-11-21 17:18:25 +01:00
Tõnis Tiigi
4204061141 Merge pull request #4287 from tstenner/variable_expansion_trimming
Trimming in variable substitution
2023-11-15 16:02:58 -08:00
yumemio
d6852bb912 docs: fix warning callouts
Signed-off-by: yumemio <59369226+yumemio@users.noreply.github.com>
2023-11-11 15:32:36 +09:00
Tõnis Tiigi
25e9aa8d39 Merge pull request #4382 from jsternberg/healthcheck-start-interval-note
docs: add a note that healthcheck --start-interval requires docker 25.0
2023-11-06 21:57:29 -08:00
Jonathan A. Sternberg
d064704a78 docs: add a note that healthcheck --start-interval requires docker 25.0
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2023-11-06 09:09:50 -06:00
Paul "TBBle" Hampson
98e0d8dcff Whenever copying OCI Platform data, include OSVersion and OSFeatures
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>
2023-11-03 12:19:29 +09:00
Frank Villaro-Dixon
828749d4eb frontend/dockerfile/dockerfile2llb: errmsg: quote build target
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>
2023-11-01 18:38:12 +01:00
Tristan Stenner
4f459a4cd1 Add string trimming (#, %, ##, %%) in variable expansion
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>
2023-11-01 13:32:46 +01:00
Justin Chadwell
9dd188bdb6 Merge pull request #3001 from DYefimov/feature/copy_parents 2023-11-01 12:01:55 +00:00
omahs
74b526105d fix typos
Signed-off-by: omahs <73983677+omahs@users.noreply.github.com>
2023-10-31 08:09:36 +01:00
Aaron Lehmann
42988ce39d dockerfile2llb: Add a MainContext option to ConvertOpt
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>
2023-10-24 18:25:38 -07:00
Paul "TBBle" Hampson
6c97753fb0 Revendor opencontainers/image-spec to v1.1.0-rc5
This brings in new string constants ImageIndexFile and ImagesBlobsDir.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2023-10-17 17:35:14 +09:00
CrazyMax
c444964c2e Merge pull request #4314 from dvdksn/mv-dockerignore-docs
docs: mv .dockerignore help to context docs
2023-10-11 03:11:55 -07:00
Tonis Tiigi
dce051940e dockerfile: add --parents flag for COPY
Co-Authored-By: Dmitrii Efimov <5221640+DYefimov@users.noreply.github.com>
Co-Authored-By: Justin Chadwell <me@jedevc.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2023-10-11 09:52:01 +01:00
David Karlsson
7f4428f313 docs: mv .dockerignore help to context docs
.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>
2023-10-10 18:15:39 +02:00
Kohei Tokunaga
0a07ae10a1 Update go to 1.21
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-10-06 11:49:27 +09:00
CrazyMax
ef9fb6f31d hack(dockerfile-frontend): remove daily release type
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-09-15 08:45:34 +02:00
Akihiro Suda
2f8292cf79 exporter/containerimage: new option: rewrite-timestamp
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>
2023-09-14 12:12:04 +09:00
Tõnis Tiigi
c7e7f441ec Merge pull request #4194 from jedevc/fix-dockerfile2llb-example
dockerfile2llb: prevent panic in ./examples/dockerfile2llb helper
2023-09-13 09:44:42 -07:00
Justin Chadwell
bd9e78aeb5 dockerfile2llb: set default llb.Local when client is not available
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>
2023-09-13 13:08:34 +01:00
Tõnis Tiigi
12bbf0724c Merge pull request #4188 from thaJeztah/switch_reference
migrate to new github.com/distribution/reference v0.5.0
2023-09-08 15:58:26 -07:00
Sebastiaan van Stijn
2d3722e50a migrate to github.com/distribution/reference v0.5.0
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>
2023-09-05 15:29:27 +02:00
Tonis Tiigi
1bbf73efa9 llb: avoid duplicate instances of sourcemaps in provenance
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>
2023-08-31 08:28:40 -07:00
Sebastiaan van Stijn
376e9c858c deprecate frontend/dockerfile/dockerignore
This package was moved to github.com/moby/patternmatcher/ignorefile.
Mark the alias as deprecated.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-23 00:13:57 +02:00
Sebastiaan van Stijn
cb63b9ccba replace dockerfile/dockerignore with patternmatcher/ignorefile
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>
2023-08-23 00:13:47 +02:00
Justin Chadwell
c5402622bb lint: add protolint config
And tidy up the proto definitions to follow the new linting rules.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-08-10 13:11:18 +01:00
Justin Chadwell
a1deb3ee6a Merge pull request #4012 from kzys/dockerignore-docs 2023-08-07 15:08:14 +01:00
Justin Chadwell
c57c4aebe9 tests: refactor integration test package
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>
2023-08-03 12:33:54 +01:00
Justin Chadwell
d0f47df5e5 test: use integration.Tmpdir consistently
Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-08-03 12:16:01 +01:00
Justin Chadwell
659fba6dd2 Merge pull request #4093 from jedevc/tempdir-errors 2023-08-03 10:32:51 +01:00
Tõnis Tiigi
dd0053cdce Merge pull request #4085 from dvdksn/docs/dockerfile-1.6-release
docs: removed labs ref for ADD checksum and git
2023-08-03 10:46:42 +03:00
David Karlsson
dcc83f8c0b docs: removed labs ref for ADD checksum and git
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>
2023-08-03 09:32:24 +02:00
Tõnis Tiigi
3fff1a66b4 Merge pull request #3980 from AkihiroSuda/fix-repro-workarounds-description
docs/build-repro.md: fix description about squashing
2023-08-03 10:17:19 +03:00
Justin Chadwell
f751a91941 tests: refactor Tmpdir as a test helper
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>
2023-08-02 16:24:23 +01:00
Sebastiaan van Stijn
7eb2ceafc3 frontend/dockerfile/dockerignore: remove hard-coded filename from error
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>
2023-07-26 13:18:24 +02:00
Sebastiaan van Stijn
d116081189 frontend/dockerfile/dockerignore: touch-up godoc and code
Use "doc links" where possible, and better describe the function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-26 13:15:25 +02:00
Sebastiaan van Stijn
01b25b13d9 frontend/dockerfile/dockerignore: cleanup unit test
- 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>
2023-07-26 13:15:22 +02:00
Akihiro Suda
075835529a docs/build-repro.md: fix description about squashing
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>
2023-07-19 14:39:19 +09:00
Kazuyoshi Kato
487ef0329a Clarify the behavior of wildcards in .dockerignore file
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>
2023-07-11 21:11:38 -07:00
Justin Chadwell
5230f200ce filesync: escape special query characters
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>
2023-07-11 15:07:53 +01:00
Tõnis Tiigi
f21a96cdff Merge pull request #4003 from tonistiigi/oci-cgroupns
oci: make sure cgroupns is enabled if supported
2023-07-10 13:57:51 -07:00
Tõnis Tiigi
595bfa218f Merge pull request #3908 from gabriel-samfira/handle-platform-file-paths
Handle file paths base on target platform
2023-07-10 13:57:23 -07:00
Tõnis Tiigi
6b9909494a Merge pull request #3956 from cpuguy83/source_policy_resolve_image
Fix ResolveImageConfig to evaluate source policy
2023-07-10 13:02:59 -07:00
Gabriel Adrian Samfira
f1657ecc14 Fix various nits
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2023-07-10 22:58:36 +03:00