From ef997fd6d0026d94d2ce8e73b5ac70a6d459c0fa Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Thu, 25 May 2023 13:58:52 +0100 Subject: [PATCH] bake: fix BAKE_CMD_CONTEXT relative path resolution Signed-off-by: Justin Chadwell --- bake/bake.go | 4 ++++ tests/bake.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/bake/bake.go b/bake/bake.go index b3427c07..8dd3b979 100644 --- a/bake/bake.go +++ b/bake/bake.go @@ -1000,6 +1000,10 @@ func checkPath(p string) error { } return err } + p, err = filepath.Abs(p) + if err != nil { + return err + } wd, err := os.Getwd() if err != nil { return err diff --git a/tests/bake.go b/tests/bake.go index 0e64d1d1..7e17aa53 100644 --- a/tests/bake.go +++ b/tests/bake.go @@ -20,6 +20,7 @@ func bakeCmd(sb integration.Sandbox, dir string, args ...string) (string, error) var bakeTests = []func(t *testing.T, sb integration.Sandbox){ testBakeRemote, + testBakeRemoteCmdContext, } func testBakeRemote(t *testing.T, sb integration.Sandbox) { @@ -51,3 +52,37 @@ EOT require.FileExists(t, filepath.Join(dirDest, "foo")) } + +func testBakeRemoteCmdContext(t *testing.T, sb integration.Sandbox) { + bakefile := []byte(` +target "default" { + context = BAKE_CMD_CONTEXT + dockerfile-inline = <