From 566f41b598b350c2e92df69a4b8392863ae47faf Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Wed, 12 Apr 2023 11:12:46 +0100 Subject: [PATCH] build: avoid file resolution of dockerfile urls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dockerfiles can be HTTP URLs as well as local paths 🤦 We just copy the same logic we use for resolving context paths, and apply it here as well. Signed-off-by: Justin Chadwell --- commands/build.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/commands/build.go b/commands/build.go index 64545cfd..ce29f1ca 100644 --- a/commands/build.go +++ b/commands/build.go @@ -30,6 +30,7 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" dockeropts "github.com/docker/cli/opts" + "github.com/docker/docker/builder/remotecontext/urlutil" "github.com/docker/docker/pkg/ioutils" "github.com/moby/buildkit/client" "github.com/moby/buildkit/exporter/containerimage/exptypes" @@ -689,9 +690,11 @@ func resolvePaths(options *controllerapi.BuildOptions) (_ *controllerapi.BuildOp } } if options.DockerfileName != "" && options.DockerfileName != "-" { - options.DockerfileName, err = filepath.Abs(options.DockerfileName) - if err != nil { - return nil, err + if !urlutil.IsURL(options.DockerfileName) { + options.DockerfileName, err = filepath.Abs(options.DockerfileName) + if err != nil { + return nil, err + } } } var contexts map[string]string