bake: add file-relative path opt-in#3935
Open
crazy-max wants to merge 1 commit into
Open
Conversation
Member
Author
|
Needs docs follow-up: https://docs.docker.com/build/building/variables/#build-tool-configuration-variables |
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
fc54769 to
4ce75f7
Compare
tonistiigi
reviewed
Jul 6, 2026
tonistiigi
left a comment
Member
There was a problem hiding this comment.
Looks like default . does not atm take the relative mode into account
t.Run("default-context-in-subdirectory", func(t *testing.T) {
bakefile := []byte(`
target "default" {
dockerfile-inline = <<EOT
FROM scratch
COPY marker /marker
EOT
}
`)
dir := tmpdir(
t,
fstest.CreateDir("definitions", 0700),
fstest.CreateFile("definitions/docker-bake.hcl", bakefile, 0600),
fstest.CreateFile("definitions/marker", []byte("marker"), 0600),
)
dirDest := t.TempDir()
out, err := bakeCmd(
sb,
withDir(dir),
withArgs("--file", "definitions/docker-bake.hcl", "--set", "*.output=type=local,dest="+dirDest),
withEnv("BUILDX_BAKE_FILE_RELATIVE_PATHS=1"),
)
require.NoError(t, err, out)
require.FileExists(t, filepath.Join(dirDest, "marker"))
})
| (typically `;` on Windows and `:` elsewhere), but can be changed with `BUILDX_BAKE_PATH_SEPARATOR`. | ||
|
|
||
| By default, local directory build contexts in Bake files are resolved from the | ||
| current working directory. To opt in to resolving local directory build contexts |
Member
There was a problem hiding this comment.
Why the "first" bake file? Rather than "current" bake file. Even if this is more complicated, I think that should be the difference as the benefit of this method is that there isn't one global target directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1028
fixes #197
This adds an opt-in Bake mode that resolves local directory paths in
target.contextandtarget.contextsrelative to the directory of the first Bake file whenBUILDX_BAKE_FILE_RELATIVE_PATHS=1is set.Bake now accepts a parser option that rebases local directory build contexts after HCL or Compose files are parsed. The
buildx bakecommand enables this option fromBUILDX_BAKE_FILE_RELATIVE_PATHS, whilecwd://remains available for paths that should stay relative to the invocation directory.