diff --git a/commands/bake.go b/commands/bake.go index 565a72b5..4b0b9370 100644 --- a/commands/bake.go +++ b/commands/bake.go @@ -292,13 +292,17 @@ func saveLocalStateGroup(dockerCli command.Cli, ref string, lsg localstate.State } func readBakeFiles(ctx context.Context, nodes []builder.Node, url string, names []string, stdin io.Reader, pw progress.Writer) (files []bake.File, inp *bake.Input, err error) { - var lnames []string - var rnames []string + var lnames []string // local + var rnames []string // remote + var anames []string // both for _, v := range names { if strings.HasPrefix(v, "cwd://") { - lnames = append(lnames, strings.TrimPrefix(v, "cwd://")) + tname := strings.TrimPrefix(v, "cwd://") + lnames = append(lnames, tname) + anames = append(anames, tname) } else { rnames = append(rnames, v) + anames = append(anames, v) } } @@ -317,7 +321,7 @@ func readBakeFiles(ctx context.Context, nodes []builder.Node, url string, names if url != "" { lfiles, err = bake.ReadLocalFiles(lnames, stdin, sub) } else { - lfiles, err = bake.ReadLocalFiles(append(lnames, rnames...), stdin, sub) + lfiles, err = bake.ReadLocalFiles(anames, stdin, sub) } return nil }) diff --git a/tests/bake.go b/tests/bake.go index be4b27a6..a2af62cf 100644 --- a/tests/bake.go +++ b/tests/bake.go @@ -24,6 +24,7 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){ testBakeRemote, testBakeRemoteCmdContext, testBakeRemoteLocalOverride, + testBakeLocalCwdOverride, testBakeRemoteCmdContextOverride, testBakeRemoteContextSubdir, testBakeRemoteCmdContextEscapeRoot, @@ -173,6 +174,41 @@ EOT require.FileExists(t, filepath.Join(dirDest, "bar")) } +func testBakeLocalCwdOverride(t *testing.T, sb integration.Sandbox) { + bakeFile := []byte(` +target "default" { + dockerfile-inline = <